﻿Object.extend = function(dest, source, replace)
{
    for(prop in source)
    {
        if(replace == false && dest[prop] != null) continue;
        dest[prop] = source[prop];
    }
    return dest;
};
Object.extend(Function.prototype,
{
getArguments: function()
{
    var args = [];
    for(var i=0; i<this.arguments.length; i++)args.push(this.arguments[i]);
    return args;
}
,apply: function(o, a)
{
    var r, x = "__fapply";
    if(typeof o != "object") o =
    {
    };
    o[x] = this;
    var s = "r = o." + x + "(";
    for(var i=0; i<a.length; i++)
    {
        if(i>0) s += ",";
        s += "a[" + i + "]";
    }
    s += ");";
    eval(s);
    delete o[x];
    return r;
}
,bind: function(o)//
{
    if(!window.__objs)
    {
        window.__objs = [];
        window.__funcs = [];
    }
    var objId = o.__oid;
    if(!objId)__objs[objId = o.__oid = __objs.length] = o;
    var me = this;
    var funcId = me.__fid;
    if(!funcId)__funcs[funcId = me.__fid = __funcs.length] = me;
    if(!o.__closures)o.__closures = [];
    var closure = o.__closures[funcId];
    if(closure)return closure;
    o = null;
    me = null;
return __objs[objId].__closures[funcId] = function()
{
    return __funcs[funcId].apply(__objs[objId], arguments);
};
}
,bindAsEventListener:function(o)
{
if(!window.__objs)
{
    window.__objs = [];
    window.__funcs = [];
}
var objId = o.__oid;
if(!objId)__objs[objId = o.__oid = __objs.length] = o;
var me = this;
var funcId = me.__fid;
if(!funcId)__funcs[funcId = me.__fid = __funcs.length] = me;
if(!o.__closures)o.__closures = [];
var closure = o.__closures[funcId];
if(closure)return closure;
o = null;
me = null;
return __objs[objId].__closures[funcId] = function(event)
{
    return __funcs[funcId].apply(__objs[objId], [event || window.event]);
};
}
}
, false);
Object.extend(String.prototype,
{
trimLeft: function()
{
    return this.replace(/^\s*/,"");
}
,trimRight: function()
{
    return this.replace(/\s*$/,"");
}
,trim: function()
{
    return this.trimRight().trimLeft();
}
}
, false);
Object.extend(Array.prototype,
{
push: function(o)
{
    this[this.length] = o;
}
,clear: function()
{
    this.length = 0;
    return this;
}
,shift: function()
{
    if(this.length == 0) return null;
    var o = this[0];
    for(var i=0; i<this.length-1; i++)this[i] = this[i + 1];
    this.length--;
    return o;
}
}
, false);
Object.extend(window,
{
$: function()
{
    var elements = new Array();
    for(var i=0; i<arguments.length; i++)
    {
        var e = arguments[i];
        if(typeof e == 'string')e = document.getElementById(e);
        if (arguments.length == 1)return e;
        elements.push(e);
    }
    return elements;
}
,Class:
{
create: function()
{
return function()
{
    if(typeof this.initialize == "function")this.initialize.apply(this, arguments);
}
}
}
}
, false);
function checkBrowse()
{
    if(navigator.userAgent.toLowerCase().indexOf('msie')>0)window.brw='ie';
    else if(navigator.userAgent.toLowerCase().indexOf('firefox')>0)window.brw='ff';
    else window.brw='ie';
    if(brw!='ie')
    {
        if( document.implementation.hasFeature("XPath", "3.0") )
        {
XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
{
    if( !xNode )
    {
        xNode = this;
    }
    var oNSResolver = this.createNSResolver(this.documentElement);
    var aItems = this.evaluate(cXPathString, xNode, oNSResolver,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    var aResult = [];
    for( var i = 0; i < aItems.snapshotLength; i++)
    {
        aResult[i] = aItems.snapshotItem(i);
    }
    return aResult;
};
Element.prototype.selectNodes = function(cXPathString)
{
    if(this.ownerDocument.selectNodes)
    {
        return this.ownerDocument.selectNodes(cXPathString, this);
    }
    else
    {
        throw "For XML Elements Only";
    }
};
XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
{
    if( !xNode )
    {
        xNode = this;
    }
    var xItems = this.selectNodes(cXPathString, xNode);
    if( xItems.length > 0 )
    {
        return xItems[0];
    }
    else
    {
        return null;
    }
};
Element.prototype.selectSingleNode = function(cXPathString)
{
    if(this.ownerDocument.selectSingleNode)
    {
        return this.ownerDocument.selectSingleNode(cXPathString, this);
    }
    else
    {
        throw "For XML Elements Only";
    }
};
}
XMLDocument.prototype.loadXML = function(xmlString)
{
    var childNodes = this.childNodes;
    for (var i = childNodes.length - 1; i >= 0; i--)this.removeChild(childNodes[i]);
    var dp = new DOMParser();
    var newDOM = dp.parseFromString(xmlString, "text/xml");
    var newElt = this.importNode(newDOM.documentElement, true);
    this.appendChild(newElt);
};
XMLDocument.prototype.__proto__.__defineGetter__("xml", function ()
{
    try
    {
        return new XMLSerializer().serializeToString( this );
    }
    catch (ex)
    {
        var d=document.createElement("div");
        d.appendChild( this .cloneNode( true ));
        return d.innerHTML;
    }
}
);
Element.prototype.__proto__.__defineGetter__("xml", function ()
{
    try
    {
        return new XMLSerializer().serializeToString( this );
    }
    catch (ex)
    {
        var d = document.createElement("div");
        d.appendChild( this .cloneNode( true ));
        return d.innerHTML;
    }
}
);
XMLDocument.prototype.__proto__.__defineGetter__("text" , function ()
{
    return this.firstChild.textContent
}
);
Element.prototype.__proto__.__defineGetter__("text" , function ()
{
    return this.textContent
}
);
}
if(!window.XMLHttpRequest)
{
window.XMLHttpRequest=function()
{
    var xmlHttp=null;
    var progids=['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
    for(var i=0;i<progids.length;i++)
    {
        try
        {
            xmlHttp=new ActiveXObject(progids[i]);
            break;
        }
        catch(e)
        {
        }
    }
    if(xmlHttp==null)
    {
        alert('无法创建对象');
    }
    return xmlHttp;
};
}
}
checkBrowse();
var FloatBox=function()
{
};
FloatBox.prototype=
{
initialize:function(parent)
{
this.parent=parent;
}
,create:function(child,params)
{
var cfg=
{
    x:0,y:0
};
Object.extend(cfg,params,true);
var div=this.createDiv('dragContainer',cfg.x,cfg.y);
if(typeof(child)=='string') div.innerHTML=child;
else if(typeof(child)=='object') div.appendChild(child);
else
{
    return false;
}
this.dragBox=this.parent.appendChild(div);
if(params&&params.type&&params.type=='swf')
{
    this.dragBoxPoint=this.dragBox.appendChild(this.createDiv('dragPoint',0,0,20,20,100));
    this.dragBoxPoint.style.backgroundColor='#FF0000';
}
else
{
    this.dragBoxPoint=this.dragBox;
}
this.dragBoxPoint.onmousedown=this.box_mousedown.bindAsEventListener(this);
}
,createAdPreview:function(parent,src,w,h,x,y)
{
this.initialize(parent);
var obj=this.getAdHtml(src,w,h);
if(!obj)
{
    return false;
}
var htmlStr=obj.html;
var params=
{
    type:obj.type
};
if(x&&y)
{
    params.x=x;
    params.y=y;
}
this.create(htmlStr,params);
}
,box_mousedown:function(evt)
{
if(!evt) evt=window.event;
var d=document;
var x=evt.clientX-this.dragBox.offsetLeft;
var y=evt.clientY-this.dragBox.offsetTop;
var _this=this;
if(_this.dragBox.setCapture)this.dragBox.setCapture();
else if(window.captureEvents)window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=function(evt)
{
    if(!evt) evt=window.event;
    _this.dragBox.style.left=evt.clientX-x;
    _this.dragBox.style.top=evt.clientY-y;
};
d.onmouseup=function(evt)
{
    if(!evt) evt=window.event;
    if(_this.dragBox.releaseCapture)_this.dragBox.releaseCapture();
    else if(window.captureEvents)window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
    d.onmousemove=null;
    d.onmouseup=null;
    if(_this.mymouseup) _this.mymouseup(evt);
};
evt.cancelBubble=true;
return false;
}
,setEvent:function(eventType,fun)
{
switch(eventType)
{
    case 'onmousedown':this.mymousedown=function(evt)
    {
        fun(evt);
    };
    break;
    case 'onmousemove':this.mymousemove=function(evt)
    {
        fun(evt);
    };
    break;
    case 'onmouseup':this.mymouseup=function(evt)
    {
        fun(evt);
    };
    break;
    default:break;
}
}
,getPos:function()
{
    var x=this.dragBox.offsetLeft;
    var y=this.dragBox.offsetTop;
    return{x:x,y:y};
}
,getAdHtml:function(src,w,h)
{
    var ext=src.substring(src.lastIndexOf('.')+1,src.length).toLowerCase();
    var str='';
    if(ext=='png')
    {
        str='<div width='+w+'px height='+h+'px style="position:absolute;left:-'+parseInt(w/2)+'px;top:-'+parseInt(h/2)+'px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+src+',sizingMethod=scale);width:'+w+'px;height:'+h+'px;cursor:pointer;"></div>';
    }
    else if(ext=='swf')
    {
        str='<div style="position:absolute;left:-'+parseInt(w/2)+'px;top:-'+parseInt(h/2)+'px;"><object _ad=1 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'"> <param name="movie" value="'+src+'"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="'+src+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></div>';
    }
    else if(ext=='gif'||ext=='jpg')
    {
        str='<img src="'+src+'" width='+w+'px height='+h+'px style="position:absolute;left:-'+parseInt(w/2)+'px;top:-'+parseInt(h/2)+'px;width:'+w+'px;height:'+h+'px;cursor:pointer">';
    }
    else
    {
        return null;
    }
    return{html:str,type:ext};
}
,createDiv:function(id,left,top,width,height,z,type)
{
    left=left?left:0;
    top=top?top:0;
    var elm=document.createElement('div');
    elm.id=id;
    elm.style.left=left+'px';
    elm.style.top=top+'px';
    if(z) elm.style.zIndex=z;
    if(width) elm.style.width=width+'px';
    if(height) elm.style.height=height+'px';
    elm.style.position=type?'relative':'absolute';
    return elm;
    }
};
function vOption()
{
    this.graph='poly';
    this.filled=false;
    this.fillcolor='#FFFFFF';
    this.stroked=true;
    this.strokecolor='#FF0000';
    this.strokeweight=1;
    this.startarrow='none';
    this.endarrow='none';
    this.closed=false;
}
function vPolyline(id,parent,arrX,arrY,option)
{
    this.id=id;
    this.arrX=(arrX==null)?[]:arrX;
    this.arrY=(arrY==null)?[]:arrY;
    this.option=(option==null)?new vOption():option;
    this.graph=this.option.graph;
    this.parent=parent;
    this.shiftX=0;
    this.shiftY=0;
    this.zoom=1;
}
vPolyline.prototype=
{
    drawPolyline:function()
    {
        this.polylineElm=document.createElement('v:polyline');
        this.polylineElm.id=this.id;
        this.strokeElm=this.polylineElm.appendChild(document.createElement('v:stroke'));
        this.setStyle();
        this.parent.appendChild(this.polylineElm);
        this.paint();
    }
    ,setOption:function(option)
    {
        if(option==null) return;
        this.option=option;
        this.setStyle();
    }
    ,setStyle:function()
    {
        this.polylineElm.stroked=this.option.stroked;
        this.polylineElm.strokecolor=this.option.strokecolor;
        this.polylineElm.strokeweight=this.option.strokeweight;
        this.polylineElm.filled=this.option.filled;
        this.polylineElm.fillcolor=this.option.fillcolor;
        if(this.startarrow!='none'||this.endarrow!='none')
        {
            this.strokeElm.startarrow=this.option.startarrow;
            this.strokeElm.endarrow=this.option.endarrow;
        }
    }
    ,addPoint:function(x,y,doPaint,index)
    {
        if(!index) index=this.arrY.length;
        else
        {
            if(index!=this.arrX.length)
            {
                for(var i=this.arrX.length-1;i>=index;i--)
                {
                    this.arrX[i+1]=this.arrX[i];
                    this.arrY[i+1]=this.arrY[i];
                }
            }
        }
        this.arrX[index]=x;
        this.arrY[index]=y;
        if(doPaint) this.paint();
    }
    ,addPoints:function(x,y,doPaint)
    {
        for(var i=0;i<x.length;i++)
        {
            this.arrX[this.arrX.length]=x[i];
            this.arrY[this.arrY.length]=y[i];
        }
        if(doPaint) this.paint();
    }
    ,setPoint:function(x,y,doPaint,index)
    {
        index=(index!=null&&index<=this.arrX.length)?index:this.arrX.length>0?this.arrX.length-1:0;
        this.arrX[index]=x;
        this.arrY[index]=y;
        if(doPaint) this.paint();
    }
    ,setPoints:function(x,y,doPaint)
    {
        this.arrX=x;
        this.arrY=y;
        if(doPaint) this.paint();
    }
    ,delPoint:function(index)
    {
        if(index<0||index>=this.arrX.length) return;
        this.arrX.splice(index,1);
        this.arrY.splice(index,1);
        this.paint();
    }
    ,paint:function()
    {
        var str='';
        for(var i=0;i<this.arrX.length;i++)
        {
            if(i>0) str+=',';
            str+=(this.arrX[i]-this.shiftX)*this.zoom+','+(this.arrY[i]-this.shiftY)*this.zoom;
        }
        if(this.option.closed)
        {
            if(str) str+=',';
            str+=(this.arrX[0]-this.shiftX)*this.zoom+','+(this.arrY[0]-this.shiftY)*this.zoom;
        }
        this.polylineElm.points.value=str;
    }
    ,setZoom:function(z)
    {
        this.zoom=z;
    }
    ,setShift:function(x,y)
    {
        this.shiftX=parseInt(x);
        this.shiftY=parseInt(y);
    }
    ,setXY:function()
    {
    }
    ,getPointNum:function()
    {
        return this.arrX.length;
    }
    ,getObj:function()
    {
        return this.polylineElm;
    }
    ,destroy:function()
    {
        this.parent.removeChild(this.polylineElm);
    }
};
function InfoState(map)
{
    this._state=
    {
    };
    this._curState=null;
    this._f=1;
    this.map=map;
}
InfoState.prototype=
{
    addItem:function(item)
    {
        if(this._state[item])
        {
            alert('item exist');
            return;
        }
        this._state[item]=
        {
            ids:
            {
            }
            ,f:1
        };
    }
    ,ready:function(item)
    {
        if(!this._state[item])
        {
            alert('ready err');
            return;
        }
        this.clear(item);
        this._curState=this._state[item];
        this._f=this._curState.f==1?-1:1;
        this._curState.f=this._f;
    }
    ,getState:function(id)
    {
        var ids=this._curState.ids;
        if(ids[id])
        {
            ids[id]=this._f;
            return true;
        }
        else
        {
            ids[id]=this._f;
            return false;
        }
    }
    ,clear:function(item)
    {
        if(!this._state[item])
        {
            alert('ready err');
            return;
        }
        var ids=this._state[item].ids;
        var f=this._state[item].f;
        for(var id in ids)
        {
            if(ids[id]!=f)
            {
                delete ids[id];
                var elm=$(id);
                if(elm)
                {
                    this.map.separateObj(elm);
                    elm.parentNode.removeChild(elm);
                }
            }
        }
    }
};
var mapTools=
{
    isSendMistake:false,isSendMail:false,formatLen:function(str,len)
    {
        var z=1;
        if(str.charCodeAt(0)>255||str.charCodeAt(str.length-1)>255) z=2;
        if(str.length*z<=len) return str;
        else return str.substring(0,Math.floor(len/z))+'...';
    }
    ,copyValue:function(id)
    {
        var obj=$(id);
        if(!obj) return;
        window.clipboardData.setData("Text",obj.value);
        national.showMsg("% {Copy2Clipboard:已经复制到剪贴板}!");
    }
    ,validateMistakeForm:function(form)
    {
        if (this.isSendMistake)
        {
            national.showMsg('%{noSubmitAgain:请不要重复提交}');
            return false;
        }
        var emptyRe=/^[\s ]*$/;
        if(emptyRe.test(form.content.value))
        {
            national.showMsg('%{EmptyContent: 内容不能为空}');
            return false;
        }
        form.centerX.value=mapApi.AreaUnitInfo.x;
        form.centerY.value=mapApi.AreaUnitInfo.y;
        form.entity.value=mapApi.AreaUnitInfo.AreaID;
        form.map.value=mapApi.mapid;
        if(mapApi.type==0)
        {
            this.isSendMistake=true;
            mapApi.setView_comInfoSend(true);
            setTimeout(this.errorMistake.bind(this),5000);
        }
        else
        {
            mapApi.switchComPanel (0);
            national.showMsg('%{InfoOK:您的信息已经提交}');
        }
        return true;
    }
    ,backMistake:function()
    {
        this.isSendMistake=false;
        mapApi.mistakeBack();
    }
    ,errorMistake:function()
    {
        if(!this.isSendMistake) return false;
        this.isSendMistake=false;
        this.changeSendView();
        national.showMsg('%{InfoTimeout: 超时，信息可能发送失败}！');
    }
    ,validateMailForm:function(form)
    {
        if(this.isSendMail)
        {
            national.showMsg('%{noSubmitAgain:请不要重复提交}');
            return false;
        }
        form=document.forms[form];
        var emailRe=/^\w+@\w+\.\w+$/;
        var emptyRe=/^[\s ]*$/;
        var toAddress=form.toAddress.value;
        if(!emailRe.test(toAddress))
        {
            national.showMsg ('%{ErrorEmail:接收邮件地址为空或者错误}');
            return false;
        }
        var replyAddress=form.replyAddress.value;
        if(!emptyRe.test(replyAddress)&&! emailRe.test(replyAddress))
        {
            national.showMsg('%{ErrorYourEmail:您自己的邮件地址错误}');
            return false;
        }
        var myname=form.myname.value;
        if(emptyRe.test(myname))
        {
            national.showMsg('%{EmptyName: 名字为空}');
            return false;
        }
        var mycontent=form.mycontent.value;
        if(emptyRe.test(mycontent))
        {
            national.showMsg ('%{EmptyContent:内容不能为空}');
            return false;
        }
        var url=null;
        if(mapApi.AreaUnitInfo.UnitID) url=mapApi.host+'/?cid='+mapApi.AreaUnitInfo.UnitID;
        else url=mapApi.host+'/?id='+mapApi.AreaUnitInfo.AreaID;
        form.content.value=national.formatStr ('MailContent',
        {
            YourName:myname,YourEmail:replyAddress,Url:url,Content:mycontent
        }
        );
        if(mapApi.type==0)
        {
            this.isSendMail=true;
            mapApi.setView_comInfoSend(true);
            setTimeout(this.errorMail.bind(this),5000);
        }
        else
        {
            mapApi.switchComPanel(0);
            national.showMsg('%{MailOK:您的邮件已经发送}');
        }
        form.submit();
        return true;
    }
    ,backMail:function()
    {
        this.isSendMail=false;
        mapApi.mailBack();
    }
    ,errorMail:function()
    {
        if(!this.isSendMail) return false;
        this.isSendMail=false;
        this.changeSendView();
        national.showMsg('%{MailTimeout: 超时，邮件可能发送失败}！');
    }
    ,changeSendView:function(flag)
    {
        mapApi.switchComPanel (0);
        mapApi.setView_comInfoSend(flag);;
    }
};
var national=
{
    locale:'zh_cn',repLocale:function(str)
    {
        var localeStr=this.locale;
        if(localeStr=='zh_cn')localeStr='';
        else localeStr='_'+localeStr;
        str=str.replace(/!\{Locale\}/g,localeStr);
        return str;
    }
    ,getStr:function(type,child,rep)
    {
        var o=this.getLangData(type);
        if(o&&o[child]) return o[child];
        else if(rep) return rep;
        else return '';
    }
    ,getLangData:function(type)
    {
        if(typeof(o__language)!='object') o__language=
        {
        };
        return o__language[type];
    }
    ,convertStr:function(str,type)
    {
        var src=this.getLangData(type);
        return this.reStr(str,src);
    }
    ,reStr:function(str,src)
    {
        var mode=false;
        if(typeof(src)=='object')
        {
            this.src=src;
            mode=true;
        }
        var re=/%\{(\w+):(.*?)\}/g;
        if(mode)str=str.replace(re,this.matchStr.bind(this));
        else str=str.replace(re,this.matchStr2);
        return str;
    }
    ,formatStr:function(type,params)
    {
        var o=this.getLangData('Format');
        if(!o||!o[type]) return;
        this.src=params;
        var re=/#\{(\w+)\}/g;
        return o[type].replace(re,this.matchStr3.bind(this));
    }
    ,matchStr:function(mstr,m1,m2)
    {
        if(this.src[m1]) return this.src[m1];
        else return m2;
    }
    ,matchStr2:function(mstr,m1,m2)
    {
        return m2;
    }
    ,matchStr3:function(mstr,m1)
    {
        if(this.src[m1]) return this.src[m1];
        else return '';
    }
    ,showMsg:function(str)
    {
        var src=this.getLangData('Prompt');
        str=this.reStr(str,src);
        alert(str);
    }
};
var adUtils=
{
    entityAd:
    {
    }
    ,showEntityAd:function(entityId)
    {
        if(this.entityAd[entityId])
        {
            this.renderEntityAd(this.entityAd[entityId]);
        }
        else
        {
            this.parseEntityAd(entityId);
        }
    }
    ,parseEntityAd:function(entityId)
    {
        var ids=[50,51,52];
        var url=mapApi.getUrl('entityAd',
        {
            id:ids.join(','),entityId:entityId
        }
        );
        mapApi.loadXML2(url,fun.bind(this));
function fun(value)
{
    if(value)
    {
        try
        {
            var o=eval('('+value+')');
            this.entityAd[entityId]=o||
            {
            };
        }
        catch(e)
        {
            this.entityAd[entityId]=
            {
            };
        }
    }
    else
    {
        this.entityAd[entityId]=
        {
        };
        return;
    }
    this.renderEntityAd(this.entityAd[entityId]);
}
}
,getAd:function(ad)
{
if(!ad.ex)
{
    ad.ex=
    {
    };
    var total=0;
    for(var i=0;i<ad.length;i++)
    {
        total+=ad[i].score;
    }
    ad.ex.total=total;
}
var rnd=Math.floor(ad.ex.total*Math.random())+1;
var num=0,pos=0;
for(var i=0;i<ad.length;i++)
{
    num+=ad[i].score;
    if(rnd<=num)
    {
        pos=i;
        break;
    }
}
return ad[pos];
}
,renderEntityAd:function(entityAd)
{
var ids=[50,51,52];
for(var i=0;i<ids.length;i++)
{
    var item=ids[i];
    var ads=entityAd[item];
    if(!ads||ads.length==0)
    {
        $('map_comOdDiv'+i).innerHTML='';
        continue;
    }
    var ad=this.getAd(ads);
    var htmlStr='';
    if(this.getFileExt(ad.src)=='swf') htmlStr=this.getFlashHtml(ad.src,105,50);
    else htmlStr='<a href="'+ad.url+'" target="_blank"><img src="'+ad.src+'" style="cursor:pointer;width:105px;height:50px;"></a>';
    $('map_comOdDiv'+i).innerHTML=htmlStr;
}
}
,getFlashHtml:function(src,w,h)
{
var htmlStr='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="{$Width}" height="{$Height}"> <param name="movie" value="{$Src}"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="{$Src}" width="{$Width}" height="{$Height}" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
htmlStr=htmlStr.replace('{$Src}',src).replace('{$Width}',w).replace('{$Height}',h);
return htmlStr;
}
,getFileExt:function(file)
{
if(!file) return '';
var arr=file.split('.');
return arr[arr.length-1].toLowerCase();
}
,countEntityAd:function(id)
{
var url=mapApi.getUrl('entityAdCount',
{
    id:id
}
);
mapApi.loadXML2(url,function()
{
}
);
}
};
var UserPop=
{
addUserPop:function(obj,type)
{
if(!type) type='info';
if(!this.UIClass[type])
{
    alert('not fond cls');
    return;
}
this.removeUserPop(type);
this.removeUserPopData(type);
if(!obj) return;
var container=this.UIClass[type].popData;
for(var i=0;i<obj.length;i++)
{
    this.pushUserPopData(obj[i],container);
}
this.loadUserPop();
}
,clearUserPop:function()
{
var cls=this.UIClass;
for(var item in cls)
{
    this.removeUserPop(item);
    this.removeUserPopData(item);
}
}
,pushUserPopData:function(obj,container)
{
    var targetZ=this.infoLoadLevel;
    var wh=this.zoomvalue(1,256,targetZ);
    var h=Math.floor(obj.x/wh);
    var v=Math.floor(obj.y/wh);
    var id=targetZ+','+h+','+v;
    if(!container[id]) container[id]=[];
    container[id].push(obj);
}
,removeUserPopData:function(type)
{
    var container=this.UIClass[type].popData;
    for(var item in container)
    {
        var arr=container[item];
        for(var i=0;i<arr.length;i++)
        {
            delete arr[i];
        }
        delete container[item];
    }
    container=
    {
    };
}
,loadUserPop:function()
{
    var targetZ=this.infoLoadLevel;
    var wh=this.zoomvalue(this.Zoom,256,targetZ);
    if(!this.isLoadInfo||this.Zoom>this.infoViewLevel||this.mapType!=3) return;
    for(var y=Math.floor(this.startY/wh);y<=Math.floor(this.endY/wh);y++)
    {
        for(var x=Math.floor(this.startX/wh);x<=Math.floor(this.endX/wh);x++)
        {
            this.parseUserPopData(x,y,targetZ);
        }
    }
}
,removeUserPop:function(type)
{
    var targetZ=this.infoLoadLevel;
    var wh=this.zoomvalue(this.Zoom,256,targetZ);
    if(!this.isLoadInfo||this.Zoom>this.infoViewLevel||this.mapType!=3) return;
    var cls=this.UIClass[type];
    var container=cls.popData;
    for(var y=Math.floor(this.startY/wh);y<=Math.floor(this.endY/wh);y++)
    {
        for(var x=Math.floor(this.startX/wh);x<=Math.floor(this.endX/wh);x++)
        {
            var arr=container[targetZ+','+x+','+y];
            if(!arr) continue;
            for(var i=0;i<arr.length;i++)
            {
                this.removePop(cls.getIdStr(arr[i]));
            }
        }
    }
}
,parseUserPopData:function(h,v,z)
{
    var id=z+','+h+','+v;
    var cls=this.UIClass;
    for(var item in cls)
    {
        var ui=cls[item];
        ui.createUserPopById(id);
    }
}
,createUserPop:function(e,param,type)
{
    if(!type) type='info';
    return this.UIClass[type].createUserPop(e,param);
}
,addUserPopClass:function(type,cls)
{
    this.UIClass[type]=new cls(this);
    this.objs[type]=[];
}
,createEmptyUP:function(type)
{
    var elm=document.createElement('div');
    elm._node=type;
    return elm;
}
,popObj:function(type)
{
    return this.objs[type].pop();
}
,getElementById:function(id)
{
    return $(id);
}
};
function UserPop_Info(map)
{
    this.map=map;
    this.popData=
    {
    };
};
UserPop_Info.prototype=
{
    createUserPopById:function(id)
    {
        var arr=this.popData[id];
        if(!arr) return;
        for(var i=0;i<arr.length;i++)
        {
            this.createUserPop(arr[i]);
        }
    }
    ,getIdStr:function(e)
    {
        var id=this.getUPIdStr(e.type.split('_')[0])+e.id;
        return id;
    }
    ,getCfg:function(e,param)
    {
        if(!e.type) e.type='yp_10';
        var classNames=['red_div','green_div','blue_div'];
        var classIndex=
        {
            yp_0:2,yp_1:2,yp_2:1,yp_3:2,yp_4:0,yp_5:1,yp_6:2,yp_7:2,yp_8:0,yp_9:0,yp_10:0,et_1:0,bs_1:2,bs_2:0,vr_1:2
        };
        var cfg=
        {
        };
        cfg.global=false;
        cfg.display=false;
        cfg.className=classNames[classIndex[e.type]];
        cfg.type=e.type.split('_')[0];
        cfg.idStr=this.getIdStr(e);
        cfg.img=e.type+'.gif';
        cfg.args='';
        if(param&&param.img)
        {
            var ci=classIndex[param.img];
            if(ci||ci==0)cfg.className=classNames[ci];
        }
        Object.extend(cfg,param,true);
        return cfg;
    }
    ,createUserPop:function(e,param)
    {
        alert('createUserPop');
//        var cfg=this.getCfg(e,param);
//        var elm;
//        if(this.map.objs['info'].length==0)
//        {
//            elm=document.createElement('div');
//            elm.style.cursor='pointer';
//            elm._node='info';
//            elm.onclick=this.userPop_click.bindAsEventListener(this);
//            elm.onmouseover=function(evt)
//            {
//                var src=evt.srcElement||evt.target;
//                src=this.getObj(src,'info');
//                if(src._dis) return;
//                src.parentNode.style.zIndex=100;
//                src.style.zIndex=100;
//                var obj=$('div'+src._id);
//                if(obj) obj.style.display='';
//            }
//            .bindAsEventListener(this);
//            elm.onmouseout=function(evt)
//            {
//                var src=evt.srcElement||evt.target;
//                src=this.getObj(src,'info');
//                if(src._dis) return;
//                src.parentNode.style.zIndex=5;
//                src.style.zIndex=5;
//                var obj=$('div'+src._id);
//                if(obj) obj.style.display='none';
//            }
//            .bindAsEventListener(this);
//        }
//        else
//        {
//            elm=this.map.objs['info'].pop();
//        }
//        elm._id=e.id;
//        elm._name=e.name;
//        elm._x=e.x;
//        elm._y=e.y;
//        elm._t=cfg.type;
//        elm._args=cfg.args;
//        var disStr='';
//        if(cfg.display)
//        {
//            elm._dis=1;
//        }
//        else
//        {
//            elm._dis=0;
//            disStr='display:none';
//        }
//        var str='';
//        if(this.type==1&&e.type=='-2')str='id="bus'+e.id+'" _id='+e.id+' _name="'+e.name+'" _x='+e.x+' _y='+e.y+' title="'+e.name+'"';
//        elm.innerHTML='<img src="'+this.map.apiPath+'/images/skin2/icon/'+cfg.img+'" '+str+' style="float:left;" width="27" height="37" border="0"><div id="div'+e.id+'" style="position:absolute;left:28px;white-space:nowrap;'+disStr+'" class="'+cfg.className+'"> <a href="#" class="red" title="'+national.getStr('Common','ClickHere','点击查看详细信息')+'">'+e.name +'</a></div>';
//        if(!cfg.global)this.map.createPopT(cfg.idStr,elm,e.x,e.y,15,36,5,this.infoLoadLevel);
//        else this.map.createPop(cfg.idStr,elm,e.x,e.y,15,36,5);
//        return cfg.idStr;
    }
    ,userPop_click:function(evt)
    {
        var src=evt.srcElement||evt.target;
        src=this.getObj(src,'info');
        if(this.moved>0)return;
        if(src._t=='et') this.map.showOCInfo(src._x,src._y,src._id);
        else if(src._t=='bs') this.showStationBlog(src._id,src._name,src._x,src._y);
        else if(src._t=='vr')
        {
            var arr=src._args.split(',');
            if(arr.length<3) return false;
            this.map.openwin(arr[0],src._id,arr[1],arr[2]);
        }
        else this.map.showOCInfo(src._x,src._y,0,src._id,true);
        return false;
    }
    ,getUPIdStr:function(type)
    {
        if(type=='yp') return 'up_unit';
        else if(type=='et') return 'up_entity';
        else if(type=='vr') return 'up_vr';
        else if(type=='bs') return 'busStation';
        else return 'search';
    }
    ,getObj:function(obj,type)
    {
        if(!obj) return null;
        if(obj._node==type) return obj;
        while(obj.parentNode&&obj.parentNode!=document.body)
        {
            obj=obj.parentNode;
            if(obj._node==type) return obj;
        }
        return null;
    }
//    ,
//    showStationBlog:function(id,name,x,y)
//    {
//        if(this.map.moved>3)return;
//        var sx=180*Math.pow(2,this.map.Zoom-1);
//        var sy=20*Math.pow(2,this.map.Zoom-1);
//        var htmlStr='<div style="position:absolute;left:-67px;top:153px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="24px" height="24px"> <param name="movie" value="/images/flash/kkk.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="api/images/kkk.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="24px" height="24px"></embed></object></div><div style="position:absolute;left:-53px;top:129px;"><img src="images/map/point2.gif"></div><img border="0" style="position:absolute;left:310px;top:6px;cursor:pointer" src="/images/map/close.gif" onclick="mapApi.removePop(\'pop_bus\')"><div id="Layer1"><div style="background:#fff;padding:1 0 0 1;width:332;height:230;"><div style="height:100%; width:100%; "><div style="background:#fff;height:100%; width:100%;"><iframe src="'+this.map.blogPath+'busstation.jspa?locale='+this.map.locale+'&id={@ID}" height="100%" width="100%" frameborder="0" scrolling="no" ></iframe></div></div></div></div>';
//        htmlStr=htmlStr.replace('{@ID}',id);
//        this.map.AreaUnitInfo=
//        {
//        };
//        this.map.AreaUnitInfo.AreaID=id;
//        this.map.AreaUnitInfo.AreaName=name;
//        this.map.AreaUnitInfo.x=x;
//        this.map.AreaUnitInfo.y=y;
//        this.map.AreaUnitInfo.type=3;
//        this.map.removePop('pop_bus');
//        this.map.go2xyS(parseInt(x)+sx,parseInt(y)-sy);
//        this.map.createPop('pop_bus',htmlStr,x,y,-55,165,7,this.map.infoLoadLevel);
//    }
};
var mapApiClass=Class.create();
mapApiClass.prototype=
{
    initialize:function()
    {
        this.author='qhb';
        this.company='Guangzhou Yidong network co.,Ltd';
        this.version='0.3 beta';
        this.curID=[];
        this.oldID=[];
        this.globalPop=[];
        this.hsXmlFlag=[];
        this.hsAreaFlag=[];
        this.infoFlag=[];
        this.areaData=[];
        this.busStationData=[];
        this.metroData=[];
        this.adData=[];
        this.p_hs=
        {
        };
        this.p_hs.list=[];
        this.popData=[];
        this.ptInfo=
        {
        };
        this.tempData=
        {
        };
        this.busLine=
        {
            up:[],down:[],ids:
            {
            }
        };
        this.isInit=false;
        this.isLoadBusStation=false;
        this.isLoadRoadName=false;
        this.isLoadRoadLine=false;
        this.isLoadAd=true;
        this.isShowAUInfo=true;
        this.hsLoadType='text';
        this.hsLoadLevel=3;
        this.hsViewLevel=100;
        this.infoLoadType='text';
        this.infoLoadLevel=3;
        this.infoViewLevel=100;
        this.minimapSize=16;
        this.infoState=new InfoState(this);
        this.infoState.addItem('info');
        this.UIClass=
        {
        };
        this.UIClass['info']=new UserPop_Info(this);
        this.objs=
        {
        };
        this.objs['info']=[];
        this.checkBrowse();
        this.setValue();
        this.setBase();
        if(this.popStr!='') this.createWelcomePop();
    }
    ,init:function(x,y,l)
    {
        if(this.isInit) return;
        if(x)
        {
            this.CenterX=this.getXY(x);
            this.defValue.x=x;
        }
        if(y)
        {
            this.CenterY=this.getXY(y);
            this.defValue.y=y;
        }
        document.onmousedown=this.doc_mousedown.bindAsEventListener(this);
        document.onmousemove=this.doc_mousemove.bindAsEventListener(this);
        document.onmouseup=this.doc_mouseup.bindAsEventListener(this);
        document.onmousewheel=this.doc_mousewheel.bindAsEventListener(this);
        document.ondblclick=this.doc_dblclick.bindAsEventListener(this);
        document.ondragstart=function()
        {
            return false;
        };
        document.onselectstart=function()
        {
            return false;
        };
        document.oncontextmenu=function()
        {
            return false;
        };
        document.onkeydown=this.doc_keydown.bindAsEventListener(this);
        document.onkeyup=this.doc_keyup.bindAsEventListener(this);
        if(this.isLoadMiniMap)
        {
            //this.minimaparea.style.display='';
            this.doc_resize();
        }
       // if(this.isLoadZoomBar)this.zoombar.style.display='';
        this.setMapPos();
        if(this.loadType||l) this.setMap();
        this.isInit=true;
    }
    ,setValue:function()
    {
        this.defValue=
        {
            w:0,h:0,x:53100,y:40900,z:3,d:3,loadType:1,type:0,mpx:0,mpy:0,msize:16,mapid:1,ruler:0,code:'utf-8',apiSrc:'js/mapApi_out.js',apiPath:'/O.cn_My/',domain:'gz',resourcePath:'http://www.o.cn/resource/',mapPath:'',filePath:'',hsPath:'',entityPath:'',unitPath:'',homePath:'',blogPath:'',locale:'zh_cn',isLoadMiniMap:true,isLoadZoomBar:true,isLoadHotspot:true,isLoadInfo:true,isLoadAd:true
        };
        Object.extend(this.defValue,parent.o__setValue,true);
        with(this.defValue)
        {
            this.bodyWidth=document.body.clientWidth;
            this.bodyHeight=document.body.clientHeight;
            this.mapWidth=w==0?this.bodyWidth:(parseInt(w)>200?parseInt(w):200);
            this.mapHeight=h==0?this.bodyHeight:(parseInt(h)>200?parseInt(h):200);
            this.CenterX=this.zoomvalue(z,parseInt(x),1);
            this.CenterY=this.zoomvalue(z,parseInt(y),1);
            this.Zoom=parseInt(z);
            this.mapType=parseInt(d);
            this.isLoadMiniMap=isLoadMiniMap;
            this.isLoadZoomBar=isLoadZoomBar;
            this.isLoadInfo=isLoadInfo;
            this.isLoadAd=isLoadAd;
            this.isLoadHotspot=isLoadHotspot;
            this.loadType=parseInt(loadType);
            this.type=parseInt(type);
            this.locale=locale;
            this.apiPath=apiPath;
            this.resourcePath=resourcePath;
            this.mapPath=mapPath;
            this.resourcePage='/map/loadxml.jspa';
            this.entityPath=entityPath;
            this.unitPath=unitPath;
            this.popStr=popStr;
            this.mpx=mpx;
            this.mpy=mpy;
            this.minimapSize=msize;
            this.mapid=mapid;
            this.ruler=ruler;
            this.parent=parent;
            if(domain.indexOf('.')==-1)
            {
                this.host='http://'+domain+'.o.cn';
            }
            else
            {
                this.host='http://'+domain;
            }
            if(!mapPath)
            {
                this.mapPath=this.resourcePath+'mappic/';
            }
            else
            {
                this.mapPath=mapPath;
            }
            if(!entityPath)
            {
                this.entityPath=this.resourcePath+'js/entity/';
                this.unitPath=this.resourcePath+'js/unit/';
            }
            else
            {
                this.entityPath=entityPath;
                this.unitPath=unitPath;
            }
            if(!hsPath)
            {
                this.hsPath=this.resourcePath+'js/map/';
            }
            else
            {
                this.hsPath=hsPath;
            }
            if(!filePath)
            {
                this.filePath=this.resourcePath+'file/';
            }
            else
            {
                this.filePath=filePath;
            }
            if(!homePath)
            {
                this.homePath=this.host+'/';
            }
            else if(homePath.indexOf('http')!=-1)
            {
                this.homePath=homePath;
            }
            else
            {
                this.homePath=this.host+'/'+homePath;
            }
            if(!blogPath)
            {
                this.blogPath='http://blog.o.cn/';
            }
            else if(blogPath.indexOf('http')!=-1)
            {
                this.blogPath=blogPath;
            }
            else
            {
                this.blogPath=this.host+'/'+blogPath;
            }
        }
        if(this.mapid)
        {
            this.mapPath+=this.mapid+'/';
            this.entityPath+=this.mapid+'/';
            this.unitPath+=this.mapid+'/';
            this.hsPath+=this.mapid+'/';
        }
        if(this.mapPath.indexOf('http')==-1) this.mapPath=this.host+this.mapPath;
        if(this.resourcePage.indexOf('?')==-1) this.resourcePage+='?';
        this.isHost=true;
        if(document.domain!=this.host.replace('http://',''))this.isHost=false;
        if(this.type>10)
        {
            if(!this.isHost) this.loadJsData=true;
        }
        else if(this.type==1)
        {
        }
        if(this.loadJsData)
        {
            this.hsLoadLevel=3;
            this.hsLoadType='';
            this.infoLoadType='';
        }
        if(this.locale=='zh_tw') this.localeExt='_'+this.locale;
        else this.localeExt='';
        national.locale=this.locale;
        this.args=
        {
        };
        this.args.urls=
        {
            error:'!{host}/newmap/mistake.jspa?_flowId=ledit',entityAd:'/adPage.jspa?_flowId=showAdByDiv&id=!{id}&entityId=!{entityId}',entityAdCount:'/adPage.jspa?_flowId=adClick&id=!{id}'
        };
    }
    ,getUrl:function(type,params)
    {
        var url=this.args.urls[type];
        if(!url)
        {
            alert('url error');
            return;
        }
        return this.processUrl(url,params);
    }
    ,processUrl:function(url,params)
    {
        var re=/!{(\w+)}/g;
        params=params||{};
        params['map']=this.mapid;
        params['host']=this.host;
        params['locale']=this.locale;
        params['blogPath']=this.blogPath;
        params['filePath']=this.filePath;
        return url.replace(re,function(mstr,m1)
        {
            return params[m1]
        }
        );
    }
    ,checkBrowse:function()
    {
        if(navigator.userAgent.toLowerCase().indexOf('msie')>0)window.brw='ie';
        else if(navigator.userAgent.toLowerCase().indexOf('firefox')>0)window.brw='ff';
        else window.brw='ie';
    }
    ,createDiv:function(id,left,top,width,height,z,type)
    {
        id=id?id:'div'+this.getRnd();
        left=left?left:0;
        top=top?top:0;
        var elm=document.createElement('div');
        elm.id=id;
        elm.style.left=left+'px';
        elm.style.top=top+'px';
        if(z) elm.style.zIndex=z;
        if(width) elm.style.width=width+'px';
        if(height) elm.style.height=height+'px';
        elm.style.position=type?'relative':'absolute';
        return elm;
    }
    ,getRnd:function()
    {
        var d=new Date();
        return d.getYear()+''+d.getMonth()+''+d.getDate()+''+d.getTime()+'_'+Math.floor(1000*Math.random());
    }
    ,setBase:function()
    {
        var main = document.getElementById("mymap");
        this.mapdiv=document.body.appendChild(this.createDiv('popomapdiv'));
        //this.mapdiv=main.appendChild(this.createDiv('popomapdiv'));
        this.mapdiv1=this.mapdiv.appendChild(this.createDiv('popomapdiv1'));
        this.mapdiv2=this.mapdiv.appendChild(this.createDiv('popomapdiv2'));
        this.mapdiv3=this.mapdiv.appendChild(this.createDiv('popomapdiv3'));
        this.mapdiv31=this.mapdiv3.appendChild(this.createDiv('popomapdiv31'));
        this.mapdiv32=this.mapdiv3.appendChild(this.createDiv('popomapdiv32'));
        this.mapTip=document.body.appendChild(this.createDiv('popomapdivTip'));
        this.mapAreaInfoTip=document.body.appendChild(this.createDiv('popomapdivAreaInfoTip'));
        this.mapAreaInfoTip.style.backgroundColor='lightyellow';
        this.mapAreaInfoTip.style.padding='2px';
        this.mapAreaInfoTip.style.fontSize='12px';
        this.mapAreaInfoTip.style.whiteSpace='nowrap';
        this.mapAreaInfoTip.style.display='none';
        this.setCopyRight();
        this.createHsMap();
        this.createMiniMap();
        this.createZoomBar();
        this.createComInfo();
        this.setComInfoPos(-150,0);
        this.setMap();
        if(this.loadType)
        {
            this.init();
        }
        if(this.type!=1)
        {
            this.mapdiv3.onmousemove=function(evt)
            {
                evt.cancelBubble=true;
                return true;
            }
            .bindAsEventListener(this);
            this.mapdiv3.onmouseover=this.info_onmouseover.bindAsEventListener(this);
            this.mapdiv3.onmouseout=this.info_onmouseout.bindAsEventListener(this);
        }
        window.onresize=this.doc_resize.bindAsEventListener(this);
    }
    ,setCopyRight:function()
    {
        //var htmlStr='<div class="size"><div id="divRulerNum" class="size_num">1600 mi</div><div class="size_copright"><img src="{@ApiPath}/images/copyright!{Locale}.gif" alt="'+national.getStr('Common','Copyright','都市圈版权所有')+'" width="79" height="13" style="cursor:pointer" onclick="mapApi.openwin(\'http://www.o.cn\')"></div><div class="size_left"><img src="{@ApiPath}/images/size_01.gif"></div><div id="divRuler" class="size_mid"></div><div class="size_right"><img src="{@ApiPath}/images/size_05.gif"></div></div><iframe id="map_aimIfr" name="map_aimIfr" src="" style="display:none"></iframe>';
        var htmlStr = '';
        htmlStr=htmlStr.replace(/\{@ApiPath\}/g,this.apiPath);
        htmlStr=national.repLocale(htmlStr);
        this.mapCopyRight=document.body.appendChild(this.createDiv('popomapdivCopyRight'));
        this.mapCopyRight.style.left='0px';
        this.mapCopyRight.style.top=(this.mapHeight-25)+'px';
        this.mapCopyRight.innerHTML=htmlStr;
        this.setCopyRightZoom();
    }
    ,setCopyRightZoom:function(zz)
    {
        return;
        var value=this.ruler*Math.pow(2,this.Zoom-1);
        if(zz)
        {
            value=Math.floor(value*zz);
        }
        $('divRulerNum').innerHTML=value+' mi';
    }
    ,setMap:function()
    {
        this.clrHs();
        //this.setZoomBarSignPos();
        this.loadMap();
        //if(this.loadJsData) this.loadCurXml();
        //this.loadInfo();
        //this.loadMiniMap();
    }
    ,changeMapType:function(type)
    {
        if(!type) type=3;
        if(type==this.mapType) return;
        this.clrSignBox();
        this.clrMapCompleteTimer();
        this.onMapComplete=this.getFun(this.clrAll.bind(this),this.Zoom,this.mapType,this.curID);
        this.mapType=type;
        this.setMap();
    }
    ,getFun:function(fun)
    {
        if(typeof fun == 'function')
        {
            var argu = Array.prototype.slice.call(arguments,1);
var f = function()
{
    fun.apply(null, argu);
};
return f;
}
return function()
{
};
}
,setTimeout:function(fun, delay)
{
if(typeof fun == 'function')
{
    var argu = Array.prototype.slice.call(arguments,2);
var f = (function()
{
    fun.apply(null, argu);
}
);
return window.setTimeout(f, delay);
}
return window.setTimeout(fun,delay);
}
,setInterval:function(fun, delay)
{
if(typeof fun == 'function')
{
var argu = Array.prototype.slice.call(arguments,2);
var f = (function()
{
    fun.apply(null, argu);
}
);
return window.setInterval(f, delay);
}
return window.setInterval(fun,delay);
}
,createZoomBar:function()
{
    return;
    alert('createZoomBar');
    var htmlStr='<div id="img_zbMax" title="Max 放大" onclick="mapApi.zoomax();return false;" style="position:absolute;left:0px;top:0px;cursor:pointer;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src={@ApiPath}/images/skin2/zoom+.png);width:34px;height:31px;"></div><div id="img_zoombar" style="position:absolute;left:0px;top:31px;cursor:pointer;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src={@ApiPath}/images/skin2/zoom.png);width:34px;height:94px;"></div><div id="img_zbMin" title="Min 缩小" onclick="mapApi.zoomin();return false;" style="position:absolute;left:0px;top:125px;cursor:pointer;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src={@ApiPath}/images/skin2/zoom-.png);width:34px;height:32px;"></div><div id="map_zbSign" title="缩放" style="position:absolute;left:6px;top:46px;cursor:pointer;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src={@ApiPath}/images/skin2/zoomx.png);width:22px;height:15px;"></div>';
    if(brw!='ie') htmlStr='<img src="{@ApiPath}/images/skin2/zoom+.png" width="34" height="31" border="0" id="img_zbMax" title="Max 放大" onclick="mapApi.zoomax();return false;" style="position:absolute;left:0px;top:0px;cursor:pointer"><img src="{@ApiPath}/images/skin2/zoom.png" width="34" height="94" border="0" id="img_zoombar" style="position:absolute;left:0px;top:31px;cursor:pointer"><img src="{@ApiPath}/images/skin2/zoom-.png" width="34" height="32" border="0" id="img_zbMin" title="Min 缩小" onclick="mapApi.zoomin();return false;" style="position:absolute;left:0px;top:125px;cursor:pointer"><img src="{@ApiPath}/images/skin2/zoomx.png" width="22" height="15" border="0" id="map_zbSign" title="缩放" style="position:absolute;left:6px;top:46px;cursor:pointer">';
    htmlStr="";
    htmlStr=htmlStr.replace(/\{@ApiPath\}/g,this.apiPath);
    this.zoombar=document.body.appendChild(this.createDiv('map_zoombar',this.mapWidth-40,20,0,0,10));
    this.zoombar.innerHTML=htmlStr;
    this.zoomBarSign=$('map_zbSign');
    this.zoombar.style.display='none';
   // $('img_zoombar').onclick=this.zoomBar_click.bindAsEventListener(this);
    this.setZoomBarState();
}
,setZoomBarState:function()
{
    return;
    if(this.mapHeight<250)
    {
        $('img_zoombar').style.display='none';
        $('map_zbSign').style.display='none';
        $('img_zbMin').style.top=31;
        this.isMiniZoomBar=true;
    }
    else
    {
    $('img_zoombar').style.display='';
    $('map_zbSign').style.display='';
    $('img_zbMin').style.top=125;
    this.isMiniZoomBar=false;
    }
}
,setZoomBarSignPos:function(z)
{
    return;
    if(this.isMiniZoomBar) return;
    if(!z) z=this.Zoom;
    this.zoomBarSign.style.top=(46+18*(z-1))+'px';
}
,zoomBar_click:function(evt)
{
var z=Math.round((evt.clientY-this.zoombar.offsetTop-46)/18)+1;
if(z<1||z>4) return;
this.setZoomBarSignPos(z);
this.zoomto(z);
}
,createComInfo:function()
{
    return;
    alert('createComInfo');
//    var l=Math.floor(this.mapWidth/2);
//    var t=Math.floor(this.mapHeight/2-145);
//    var htmlStr='<div style="position:absolute;left:-12px;top:132px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="24px" height="24px"> <param name="movie" value="{@ApiPath}/images/kkk.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="api/images/kkk.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="24px" height="24px"></embed></object></div><div id="map_comSendDiv" style="position:absolute;left:150px;top:180px;z-index:3;display:none">send</div><div class="windowsbox"> <div class="windows"> <div class="title"> <div class="ico"></div> <h2 id="map_comNameH">广州中信大厦中</h2> <div class="close" title="%{Close:关闭}" onClick="mapApi.hiddenOcInfo()"><a href="javascript:void(0)"></a></div> <div class="join" title="%{UnitJoin:企业入住}" onClick="mapApi.invokeParentFun(\'unitjoin\');return false;"><a href="javascript:void(0)"></a></div> </div> <div class="blank5"></div> <div class="combox"> <div id="map_comPicConDiv"> <div id="map_comPicTool" class="comimgview" style="display:none"> <div id="zoomin" class="imglink"><a id="map_comPicA1" href="#" target="_blank"><img src="{@ApiPath}/images/skin3/info/ui_zoom.gif" title="%{ZoomPic:放大图片}"/></a></div> <div id="level" class="imglink"><a href="#"><img id="map_comLevelImg" src="{@ApiPath}/images/skin2/xinxi/home.gif" title="%{EnterHomePage:进入此商家主页}" onClick="mapApi.showComBlog();return false;"/></a></div> </div> <div id="map_comPicDiv" class="comimg"><a href="#"><img id="map_comPicImg" src="{@ApiPath}/images/skin3/info/ui_test.gif"/></a></div> </div> <div id="map_comContentDiv" class="comintroduce"></div> </div> <div class="blank5"></div> <div class="geturl"><input id="url" name="url" type="text" value="http://gz.o.cn/?12312312" class="url" onMouseOver="this.className=\'urlhover\';" onMouseOut="this.className=\'url\';"/> <div class="geturlBt" title="%{Copy2Friend:你可复制此地址发送给好友分享！}"><a href="javascript:void(0)" onClick="mapTools.copyValue(\'url\');return false;">%{Copy:复制此地点}</a></div> </div> <div class="blank5"></div> <div class="tabinformation"> <div class="tabnavi"> <ul><li id="map_divComButton0" class="hit"><a href="#" onClick="mapApi.switchComPanel(0);return false;"><span>%{Summary:本楼信息}</span></a></li> <li id="map_divComButton2"><a href="#" onClick="mapApi.switchComPanel(2);return false;"><span>%{Around:周边}</span></a></li> <li id="map_divComButton3"><a href="#" onClick="mapApi.switchComPanel(3);return false;"><span>%{Mistake:纠错}</span></a></li> <li id="map_divComButton1"><a href="#" onClick="mapApi.switchComPanel(1);return false;"><span>%{HowArrive:如何到达}</span></a>< /li><li id="map_divComButton4"></li></ul> </div> <div class="blank5"></div><div id="map_divComPanel0"> <div class="tabsbox"> <div id="windowad" class="tabsboxRight"> <div id="map_comOdDiv0"></div><div class="blank5"></div> <div id="map_comOdDiv1"></div><div class="blank5"></div> <div id="map_comOdDiv2"></div> </div> <div class="tabsboxLeft"> <ul id="map_comListUl"> </ul> </div> <div class="tabspages"> <ul id="map_comPagerUl"> </ul> </div> </div></div><div id="map_divComPanel1" class="gotohere" style="display:none"> <div style="padding:10px 0px;color:#666;">%{EnterStart:请输入起始点}：<input type="text" id="txtHowArrive" size="25" class="window_txt"/></div><div style="padding:10px 0px; text-align:center;" class="gotohere_btn"><input type="button" value="%{OK:确认}" onClick="mapApi.doComAction(\'howArrive\')"/><input name="Input" type="button" value="%{Return:返回}" onClick="mapApi.switchComPanel(0);return false;"/></div></div><div id="map_divComPanel2" class="window_con_b" style="display:none"> <div class="zb01"> <div class="zb02"><img src="{@ApiPath}/images/skin2/zbimg/yp!{Locale}.gif" width="83" height="40" /></div> <div class="zb03"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>&nbsp;&nbsp;<a id="around_1_0" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Food:餐&nbsp;饮}</a> &nbsp;&nbsp;<a id="around_1_1" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Recreation:娱&nbsp;乐}< /a>&nbsp;&nbsp;<a id="around_1_2" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Hotel:住&nbsp;宿}</a> &nbsp;&nbsp;<a id="around_1_3" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Shopping:购&nbsp;物}< /a>&nbsp;&nbsp;<a id="around_1_5" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{House:房&nbsp;产}</a> </td> </tr> <tr> <td>&nbsp;&nbsp;<a id="around_1_8" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Education:教&nbsp;育}< /a>&nbsp;&nbsp;<a id="around_1_7" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Ticket:票&nbsp;务}</a> &nbsp;&nbsp;<a id="around_1_9" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Medical:医&nbsp;疗}</a> &nbsp;&nbsp;<a id="around_1_10" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Convenience:便&nbsp;民}< /a>&nbsp;&nbsp;<a id="around_1_6" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Car:汽&nbsp;车}</a>< /td> </tr> </table> </div> </div> <div class="zb01_f"> <div class="zb02"><img src="{@ApiPath}/images/skin2/zbimg/fl!{Locale}.gif" width="83" height="40" /></div> <div class="zb03"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>&nbsp;&nbsp;<a id="around_2_1" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{House2:住&nbsp;房}</a> &nbsp;&nbsp;<a id="around_2_29" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Job:工&nbsp;作}</a> &nbsp;&nbsp;<a id="around_2_78" href="#" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Friend:交&nbsp;友}</a> </td> </tr> <tr> <td>&nbsp;&nbsp;<a href="#" id="around_2_37" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Life:生&nbsp;活}</a> &nbsp;&nbsp;<a href="#" id="around_2_46" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Food2:美&nbsp;食}</a> &nbsp;&nbsp;<a href="#" id="around_2_7" class="zb03_f" onClick="mapApi.getAround(this.id)">%{Tour:旅&nbsp;游}</a> </td> </tr> </table> </div> </div> <div class="fw">%{SearchRange:搜索范围}： <input type="radio" id="around_dis" name="around_dis" value="radiobutton" /> %{Range1:1公里内} <input id="around_dis" name="around_dis" type="radio" value="radiobutton" checked="checked" /> %{Range2:500米内}</div> </div> <div id="map_divComPanel3" class="gotohere" style="display:none;"> <form action="!{error}" method="post" enctype="multipart/form-data" target="map_aimIfr" onsubmit="return mapTools.validateMistakeForm(this);"><input type="hidden" value="UNPROCESS" name="state"><input type="hidden" name="centerX" value=""><input type="hidden" name="centerY" value=""><input type="hidden" name="entity" value=""><input type="hidden" name="map" value=""><div style="padding:0px 0px 10px 0px;"> <div style="padding:5px 0px; color:#666;">%{ErrorContent:错误内容}：</div> <textarea name="content" rows="5" cols="35" class="window_txt"></textarea> </div> <div style="padding:5px 0px;color:#666;">%{Pic:图片}： <input type="file" name="file" class="window_txt"/> </div> <div style="padding:10px 0px; text-align:center;" class="gotohere_btn"> <input type="submit" value="%{Submit:提交}" name="_eventId_submit" /> <input type="reset" value="%{Reset:重置}" name="Submit52" /> </div> </form></div><div id="map_divComPanel4" class="window_send" style="display:none"><form name="mailForm" action="{@Host}/jsp/mail_back.jsp" method="post" target="map_aimIfr"> <div class="window_send_0"> <div class="window_send_1">%{Email:好友邮箱}:</div> <div><input name="toAddress" type="text" class="window_send_k_1"/><input type="hidden" name="title" value="%{Mail2Friend:推荐给好友}"><input type="hidden" name="language" value="zh-CN"><input type="hidden" name="fromAddress" value="webmaster@o.cn"><input type="hidden" name="content" value=""></div> </div> <div class="window_send_0"> <div class="window_send_1">%{YourName:您的姓名}:</div> <div><input name="myname" type="text" class="window_send_k_2" /></div> </div> <div class="window_send_0"> <div class="window_send_1">%{YourEmail:您的邮箱}:</div> <div><input name="replyAddress" type="text" class="window_send_k_2"/></div> </div> <div class="window_send_0"> <div class="window_send_1">%{MailContent:寄出内容}:</div> <div> <textarea name="mycontent" class="window_send_k_3"></textarea> </div> </div> <div class="window_send_0"> <div align="center"><div class="window_send_bt" onClick="mapTools.validateMailForm(\'mailForm\')"></div> </div> </div></form> </div> <div id="map_comBackDiv"></div> <div class="blank5"></div> </div> </div> <div class="wpoint"><img src="{@ApiPath}/images/skin3/info/ui_point.gif"></div></div>';
//    htmlStr=htmlStr.replace(/\{@ApiPath\}/g,this.apiPath);
//    htmlStr=htmlStr.replace(/\{@Host\}/g,this.host);
//    htmlStr=htmlStr.replace('!{error}',this.getUrl('error'));
//    htmlStr=national.repLocale(htmlStr);
//    htmlStr=national.convertStr(htmlStr,'EUInfo');
//    this.ocInfo=document.body.appendChild(this.createDiv('map_cominfo',l,t,397,0,10));
//    this.ocInfo.style.display='none';
//    this.ocInfo.innerHTML=htmlStr;
//    this.ocName=$('map_comNameH');
//    this.ocImg=$('map_comPicDiv');
//    this.ocImgA1=$('map_comPicA1');
//    this.ocContent=$('map_comContentDiv');
//    this.ocComList=$('map_comListUl');
//    this.ocComPager=$('map_comPagerUl');
//    this.ocComLevelImg=$('map_comLevelImg');
//    this.ocContent.onmousedown=function(evt)
//    {
//    evt.cancelBubble=true;
//    return false;
//    }
//    .bindAsEventListener(this);
//    $('map_comPicConDiv').onmouseover=function()
//    {
//    $('map_comPicTool').style.display='';
//    };
//    $('map_comPicConDiv').onmouseout=function()
//    {
//    $('map_comPicTool').style.display='none';
//    };
//    $('map_comPicConDiv').onmousemove=function(evt)
//    {
//    evt=evt?evt:event;
//    evt.cancelBubble=true;
//    return false;
//    };
}
,setComInfoPos:function(sx,sy)
{
if(sx!=null&&typeof(sx)!='number') return;
if(sy!=null&&typeof(sy)!='number') return;
if(sx==null&&this.ocInfoSx!=null) sx=this.ocInfoSx;
if(sy==null&&this.ocInfoSy!=null) sy=this.ocInfoSy;
this.ocInfoSx=sx;
this.ocInfoSy=sy;
var l=Math.floor(this.mapWidth/2)+sx;
var t=Math.floor(this.mapHeight/2-145)+sy;
//this.ocInfo.style.left=l+'px';
//this.ocInfo.style.top=t+'px';
}
,hiddenOcInfo:function()
{
if(this.ocInfo.style.display=='none') return false;
this.ocInfo.style.display='none';
this.ocName.innerHTML='&nbsp;';
this.ocContent.innerHTML='';
this.switchComPanel(0);
}
,setView_comInfoSend: function(flag)
{
    $('map_comSendDiv').style.display=flag?'':'none';
}
,setView_comInfo: function()
{
    $('map_comBackDiv').style.display='none';
    $('map_comSendDiv').style.display ='none';
}
,comInfoBack:function(i,str)
{
    $('map_divComPanel'+i).style.display ='none';
    $('map_comBackDiv').style.display='';
    $('map_comBackDiv').innerHTML =str;
    this.setView_comInfoSend(false);
}
,mistakeBack:function()
{
    if(this.comInfoPanel!=3)
    {
        national.showMsg('%{InfoOK:您的信息已经提交}');
        return;
    }
    this.comInfoBack(3, '<br /><div align="center">'+national.getStr('Prompt','InfoOK2','您的信息已经提交，谢谢您提出宝贵意见')+'！<br /><br /><a href="#" onclick="mapApi.switchComPanel(0);return false;">'+national.getStr('Common','Return','返回')+'</a><br /><br /></div>');
}
,mailBack:function()
{
    if(this.comInfoPanel!=4)
    {
        national.showMsg ('%{MailOK:您的邮件已经发送成功}');
        return;
    }
    this.comInfoBack(4,'<br /><div align="center">'+national.getStr('Prompt','MailOK','您的邮件已经发送成功')+'! <br /><br /><a href="#" onclick="mapApi.switchComPanel(0);return false;">'+national.getStr('Common','Return','返回')+'</a><br /><br /></div>');
}
,switchComPanel:function(type)
{
    for(var i=0;i<=4;i++)
    {
        $('map_divComButton'+i).className='';
        $('map_divComPanel'+i).style.display='none';
    }
    if(type=='undefined') return;
    this.setView_comInfo();
    this.comInfoPanel=type;
    if(type==2&&this.aroundid)$(this.aroundid).className='zb03_f';
    $('map_divComButton'+type).className='hit';
    $('map_divComPanel'+type).style.display='';
}
,doComAction:function(type)
{
    switch(type)
    {
        case 'howArrive':this.invokeParentFun(type,$('txtHowArrive').value);
        this.switchComPanel(0);
        break;
        default:break;
    }
}
,getAround:function(id)
{
    var pre=$(this.aroundid);
    if(pre) pre.className='zb03_f';
    this.aroundid=id;
    $(this.aroundid).className='zb03_f_c';
    var arr=id.replace('around_','').split('_');
    var disFlag=$('around_dis').checked;
    this.invokeParentFun('around',arr[0],arr[1],disFlag);
}
,invokeParentFun:function()
{
    var method=arguments[0];
    var argu = Array.prototype.slice.call(arguments,1);
    var returnValue=null;
    if(typeof this.parent[method]=='function')
    {
        returnValue=this.parent[method].apply(null,argu);
    }
    return returnValue;
}
,showOCInfo:function(x,y,id,cid,pager,noSlowF)
{
    var url='';
    var o=
    {
    };
    this.list=null;
    if(cid)url=this.unitPath+Math.floor(cid/1000)+'/'+cid+this.localeExt+'.js';
    else url=this.entityPath+Math.floor(id/1000)+'/'+id+this.localeExt+'.js';
    this.hiddenOcInfo();
    if((id!=0&&!cid)||pager)
    {
        this.ocComList.innerHTML='';
        this.ocComPager.innerHTML='';
    }
    $('url').value='';
    var x1=x-this.ocInfoSx*Math.pow(2,this.Zoom-1);
    var y1=y-this.ocInfoSy*Math.pow(2,this.Zoom-1);
    if(noSlowF)
    {
        this.setMapPos(this.getXY(x1),this.getXY(y1));
        onend.bind(this)();
    }
    else this.setMapPosS(this.getXY(x1),this.getXY(y1),this.setMiniMapPos.bind(this),onend.bind(this));
    this.loadXML2(url,fun.bind(this));
function onend()
{
    this.setMap();
    this.ocInfo.style.display='';
}
function fun(value)
{
    if(!value)return;
    var picPath='';
    if(!cid)
    {
        picPath=this.entityPath;
    }
    else
    {
        picPath=this.unitPath;
    }
    try
    {
        var o=eval('('+value+')');
    }
    catch(e)
    {
        return;
    }
    if(o.img)
    {
        o.img=this.filePath+o.img;
        o.img2=this.filePath+o.img2;
    }
    else
    {
        o.img='';
        o.img2=this.apiPath+'/images/pop/sj_pic_s.jpg';
    }
    this.ocName.innerHTML='<strong>'+mapTools.formatLen(o.name,28)+'</strong>';
    this.ocImg.innerHTML='<a href="'+o.img+'" target="_blank"><img src="'+o.img2+'" width="105" height="79" border="0"/></a>';
    this.ocImgA1.href=o.img;
    this.ocContent.innerHTML ='<b>'+national.getStr('Common','Address','地址')+':</b>'+ o.addr+'<br/><font color="red"><b>'+national.getStr('Common','Telephone','电话')+': </b>'+o.tel+'</font><br/><b>'+national.getStr('Common', 'Introduction','简介')+':</b>'+o.intro;
    if(!cid)
    {
        this.showComPager (id,1);
        this.AreaUnitInfo=
        {
        };
        this.AreaUnitInfo.AreaID=id;
        this.AreaUnitInfo.AreaName=o.name;
        this.AreaUnitInfo.UnitID=0;
        this.AreaUnitInfo.UnitName='';
        this.AreaUnitInfo.x=x;
        this.AreaUnitInfo.y=y;
        $('url').value=this.homePath+'?id='+id;
        if(this.myAreaClick) this.myAreaClick();
        //this.ocComLevelImg.src=this.apiPath+'images/skin2/xinxi/home.gif';
    }
    else
    {
        if(!this.AreaUnitInfo)this.AreaUnitInfo=
        {
        };
        if(this.AreaUnitInfo.AreaID!=o.entityId)
        {
            this.AreaUnitInfo.AreaID=o.entityId;
            this.AreaUnitInfo.AreaName='';
        }
        this.AreaUnitInfo.UnitID=cid;
        this.AreaUnitInfo.UnitName=o.name;
        this.AreaUnitInfo.blogLevel=o.blogLevel;
        this.AreaUnitInfo.blogUrl=o.blogUrl;
        this.AreaUnitInfo.x=x;
        this.AreaUnitInfo.y=y;
        $('url').value=this.homePath+'?cid='+cid;
        if(this.myUnitClick) this.myUnitClick();
        //if(o.blogLevel) this.ocComLevelImg.src=this.apiPath+'images/skin3/info/'+o.blogLevel+'.gif';
        //else this.ocComLevelImg.src=this.apiPath+'images/skin3/info/unvip.gif';
    }
    if(pager)
    {
        this.showComPager(this.AreaUnitInfo.AreaID,1);
    }
    if(this.isLoadAd)adUtils.showEntityAd(this.AreaUnitInfo.AreaID);
}
}
,showComPager:function(id,page)
{
var url=this.entityPath+Math.floor(id/1000)+'/'+id+this.localeExt+'.js';
var o=
{
};
var pagesize=10;
var comPageStr='';
var comListStr='';
this.loadXML2(url,fun.bind(this));
function fun(value)
{
    if(!value)return;
    o=eval('('+value+')');
    o.num=o.list.length;
    o.comlist=[];
    var list=o.list;
    for(var i=(page-1)*pagesize;i<o.num&&i<page*pagesize;i++)
    {
        var o1=
        {
        };
        o1.id=list[i].id;
        o1.name=list[i].name;
        o1.x=list[i].x;
        o1.y=list[i].y;
        o1.blogUrl=list[i].blogUrl;
        o1.blogLevel=list[i].blogLevel;
        o.comlist.push(o1);
    }
    if(o.num>pagesize)
    {
        var totalpages=Math.floor(o.num/pagesize);
        var vippages=0;
        if(o.num%pagesize!=0) totalpages+=1;
        var n=8;
        var startpage=vippages;
        var endpage=totalpages;
        for(j=0;j<vippages;j++)
        {
            if(page-1==j)comPageStr+='<a href="#" onclick="mapApi.showComPager('+id+','+(j+1)+');return false;" style="color:#0000FF;padding:5px;">['+(j+1)+']</a>&nbsp;';
            else comPageStr+='<a href="#" onclick="mapApi.showComPager('+id+','+(j+1)+');return false;" style="color:#0000FF;padding:5px;">'+(j+1)+'</a>&nbsp;';
        }
        if(page-n/2>=vippages)
        {
            comPageStr+='<li><a href="#" onclick="mapApi.showComPager('+id+','+(page-1)+');return false;" style="color:#999999;">‹</a></li>';
            startpage=page-n/2+1;
        }
        if(startpage+n<=totalpages)
        {
            endpage=startpage+n;
        }
        for(j=startpage;j<endpage;j++)
        {
            if(page-1==j)comPageStr+='<li class="span">'+(j+1)+'</li>';
            else comPageStr+='<li><a href="#" onclick="mapApi.showComPager('+id+','+(j+1)+');return false;">'+(j+1)+'</a></li>';
        }
        if(endpage!=totalpages)
        {
            comPageStr+='<li><a href="#" onclick="mapApi.showComPager('+id+','+(page+1)+');return false;">›</a></li>';
        }
    }
    for(var i=0;i<o.comlist.length;i++)
    {
        var o1=o.comlist[i];
//        if(o1.blogLevel)
//        {
//            var homepage='';
//            if(o1.blogUrl) homepage=this.blogPath+o1.blogUrl+'?locale='+this.locale;
//            else homepage=this.blogPath+'unit.jspa?locale='+this.locale+'&id='+o1.id;
//            comListStr+='<li><a href="'+homepage+'" target="_blank" title="'+o1.name+'"><span class="cRed">'+mapTools.formatLen(o1.name,24)+'</a><strong><img src="'+this.apiPath+'images/skin3/info/'+o1.blogLevel+'.gif" border="0" title="'+national.getStr('EUInfo',o1.blogLevel,'等级')+'">< /strong><strong><a href="#" class="viphit" onclick="mapApi.showOCInfo('+o1.x+','+o1.y+','+id+','+o1.id+');return false;" title="'+national.getStr('EUInfo','pos','定位')+'"><img src="'+this.apiPath+'images/skin3/info/local.gif" border="0"></a></strong></li>';
//        }
//        else
//        {
//            var homepage=this.blogPath+'unit.jspa?locale='+this.locale+'&id='+o1.id;
//            comListStr+='<li><a href="'+homepage+'" target="_blank" title="'+o1.name+'">'+mapTools.formatLen(o1.name,24)+'</a><strong><img src="'+this.apiPath+'images/skin3/info/unvip.gif" border="0" title="'+national.getStr('EUInfo','UnVip','等级')+'"></strong> <strong><a href="#" class="viphit" onclick="mapApi.showOCInfo('+o1.x+','+o1.y+','+id+','+o1.id+');return false;" title="'+national.getStr('EUInfo','pos','定位')+'"><img src="'+this.apiPath+'images/skin3/info/local.gif" border="0"></a></strong></li>';
//        }
    }
    this.ocComList.innerHTML=comListStr;
    this.ocComPager.innerHTML=comPageStr;
}
function addobj(x,y)
{
    var o=
    {
    };
    var n=0;
    for(var i=0;i<x.length;i++)o[n++]=x[i];
    for(var ii=x.length-1;ii>0;--ii)
    {
        for(var j=0;j<ii;j++)
        {
            if(Math.random()*2-1>0)
            {
                var temp;
                temp=o[j];
                o[j]=o[j+1];
                o[j+1]=temp;
            }
        }
    }
    for(var i=0;i<y.length;i++)o[n++]=y[i];
    o.len1=x.length;
    o.len2=y.length;
    return o;
}
}
,showComBlog:function(id)
{
var url='';
if(!id)
{
    if(!this.AreaUnitInfo.UnitID)
    {
        url=this.blogPath+'entity.jspa?locale='+this.locale+'&id='+this.AreaUnitInfo.AreaID;
    }
    else
    {
        if(this.AreaUnitInfo.blogUrl)url=this.blogPath+this.AreaUnitInfo.blogUrl+'?locale='+this.locale;
        else url=this.blogPath+'unit.jspa?locale='+this.locale+'&id='+this.AreaUnitInfo.UnitID;
    }
}
else
{
    if(typeof id=='number') url=this.blogPath+'unit.jspa?locale='+this.locale+'&id='+id;
    else url=this.blogPath+id;
}
this.openwin(url);
}
,addErrReport:function()
{
this.myCustomFun(null,'addErr');
}
,createMiniMap:function()
{
    return;
var htmlStr='<div class="viewWindow"><div id="map_divSHMiniMap" onclick="mapApi.shMiniMap();return false;" class="clickPicA"><a href="#"></a></div> <div id="map_tblminimap" class="viewMap"><div id="map_divminimapbg" class="map"></div></div></div>';
htmlStr=htmlStr.replace(/\{@ApiPath\}/g,this.apiPath);
this.minimaparea=document.body.appendChild(this.createDiv('map_divminimaparea',this.mapWidth-220,this.mapHeight-170,0,0,10));
this.minimaparea.innerHTML=htmlStr;
this.minimapbg=$('map_divminimapbg');
this.minimaptbl=$('map_tblminimap');
this.minimapelm=this.minimapbg.appendChild(this.createDiv('map_divminimapelm',7,7,200,150,1));
this.minimapelm.style.backgroundColor='#cccccc';
this.minimapelm.style.overflow='hidden';
htmlStr='<img src="{@ApiPath}/images/compass.gif" style="position:absolute;left:0px;top:120px;width:32px;height:28px;z-index:1;"><div id="map_divminimapeye" style="position:absolute;left:80px;top:60px;width:40px;height:30px;cursor:move;border:2px solid #00ff00;z-index:3"></div><div id="map_divminimapeye1" style="position:absolute;left:80px;top:60px;width:40px;height:30px;border:2px solid #00ff00;background-Color:lightyellow;filter:alpha(opacity=50);z-index:2"></div><div id="map_divminimap" style="position:absolute;left:0px;top:0px;width:200px;height:150px;overflow:hidden;"><div id="map_divminimap1" style="position:absolute;left:0px;top:0px;"></div></div>';
htmlStr=htmlStr.replace(/\{@ApiPath\}/g,this.apiPath);
this.minimapelm.innerHTML=htmlStr;
this.minimapeye=$('map_divminimapeye');
this.minimapeye1=$('map_divminimapeye1');
this.minimap=$('map_divminimap');
this.minimap1=$('map_divminimap1');
this.minimaparea.style.display='none';
this.minimaparea.onmousedown=function(evt)
{
    evt.cancelBubble=true;
    return false;
}
.bindAsEventListener(this);
this.minimapeye.onmousedown=this.minimapeye_mousedown.bindAsEventListener(this);
this.minimap.onmousedown=this.minimap_mousedown.bindAsEventListener(this);
}
,adjustMiniMapPos:function()
{
return;
var s=0;
if(this.minimaptbl.style.display=='none') s=0;
this.minimaparea.style.left=(this.mapWidth-this.minimaparea.offsetWidth-s)+'px';
this.minimaparea.style.top=(this.mapHeight-this.minimaparea.offsetHeight-s)+'px';
}
,shMiniMap:function()
{
with(this.minimaptbl.style)
{
    display=display=='none'?'':'none';
    $('map_divSHMiniMap').className=display=='none'?'clickPicB':'clickPicA';
}
if(this.minimaptbl.style.display=='') this.loadMiniMap();
this.adjustMiniMapPos();
}
,showMiniMap:function()
{
return;
this.isLoadMiniMap=true;
this.minimaparea.style.display='';
this.setMiniMapPos();
this.loadMiniMap();
}
,hiddenMiniMap:function()
{
this.minimaparea.style.display='none';
}
,minimapeye_mousedown:function(evt)
{
this.minimapeyedrag=true;
this.bmx=evt.clientX-this.minimapeye.offsetLeft;
this.bmy=evt.clientY-this.minimapeye.offsetTop;
if(brw=='ie') this.minimap.setCapture();
document.onmousemove=this.minimaparea_mousemove.bindAsEventListener(this);
document.onmouseup=this.minimaparea_mouseup.bindAsEventListener(this);
}
,minimap_mousedown:function(evt)
{
this.minimapdrag=true;
this.bmx=evt.clientX-this.minimap1.offsetLeft;
this.bmy=evt.clientY-this.minimap1.offsetTop;
this.bmx1=evt.clientX-this.minimapeye1.offsetLeft;
this.bmy1=evt.clientY-this.minimapeye1.offsetTop;
if(brw=='ie') this.minimap.setCapture();
document.onmousemove=this.minimaparea_mousemove2.bindAsEventListener(this);
document.onmouseup=this.minimaparea_mouseup2.bindAsEventListener(this);
}
,minimaparea_mousemove:function(evt)
{
if(this.minimapeyedrag)
{
    this.posx=evt.clientX-this.bmx;
    this.posy=evt.clientY-this.bmy;
    var left=this.minimap.offsetLeft;
    var top=this.minimap.offsetTop;
    var right=this.minimap.offsetWidth-this.minimapeye.offsetWidth;
    var bottom=this.minimap.offsetHeight-this.minimapeye.offsetHeight;
    var flag=true;
    if(this.posx<left||this.posx>right||this.posy<top||this.posy>bottom)
    {
        if(!this.minimaptimer)
        {
            this.minimaptimer=window.setInterval(minimapTimerFun.bind(this),20);
        }
        flag=false;
    }
    if(flag&&this.minimaptimer)
    {
        window.clearInterval(this.minimaptimer);
        this.minimaptimer=null;
    }
    this.minimapeye.style.left=this.posx+'px';
    this.minimapeye.style.top=this.posy+'px';
}
function minimapTimerFun()
{
    var s=3;
    if(this.posx<left)
    {
        this.minimap1.style.left=this.minimap1.offsetLeft+s;
        this.minimapeye1.style.left=this.minimapeye1.offsetLeft+s;
    }
    if(this.posx>right)
    {
        this.minimap1.style.left=this.minimap1.offsetLeft-s;
        this.minimapeye1.style.left=this.minimapeye1.offsetLeft-s;
    }
    if(this.posy<top)
    {
        this.minimap1.style.top=this.minimap1.offsetTop+s;
        this.minimapeye1.style.top=this.minimapeye1.offsetTop+s;
    }
    if(this.posy>bottom)
    {
        this.minimap1.style.top=this.minimap1.offsetTop-s;
        this.minimapeye1.style.top=this.minimapeye1.offsetTop-s;
    }
    if(!this.minimapTimeout)this.minimapTimeout=window.setTimeout(this.appendMiniMap.bind(this),1000);
}
}
,appendMiniMap:function()
{
var minimapWidth=200,minimapHeight=150;
var CenterX_t=Math.floor((this.minimapeye.offsetLeft+this.minimapeye.offsetWidth/2-this.minimap1.offsetLeft)*this.minimapSize);
var CenterY_t=Math.floor((this.minimapeye.offsetTop+this.minimapeye.offsetHeight/2-this.minimap1.offsetTop)*this.minimapSize);
var startX=Math.floor(CenterX_t/this.minimapSize-minimapWidth/2);
var startY=Math.floor(CenterY_t/this.minimapSize-minimapHeight/2);
var endX=startX+minimapWidth;
var endY=startY+minimapHeight;
for(var y=Math.floor(startY/256);y<=Math.floor(endY/256);y++)
{
    for(var x=Math.floor(startX/256);x<=Math.floor(endX/256);x++)
    {
        if($('m'+this.Zoom+','+x+','+y)) continue;
        this.minimap1.appendChild(this.loadpic(x,y,this.Zoom,4));
    }
}
if(this.minimapTimeout)
{
    window.clearTimeout(this.minimapTimeout);
    this.minimapTimeout=null;
}
}
,minimaparea_mousemove2:function(evt)
{
if(this.minimapdrag)
{
    var posx=evt.clientX-this.bmx;
    var posy=evt.clientY-this.bmy;
    var posx1=evt.clientX-this.bmx1;
    var posy1=evt.clientY-this.bmy1;
    var left=this.minimap.offsetLeft;
    var top=this.minimap.offsetTop;
    var right=this.minimap.offsetLeft+this.minimap.offsetWidth-this.minimapeye.offsetWidth;
    var bottom=this.minimap.offsetTop+this.minimap.offsetHeight-this.minimapeye.offsetHeight;
    this.minimap1.style.left=posx+'px';
    this.minimap1.style.top=posy+'px';
    this.minimapeye1.style.left=posx1+'px';
    this.minimapeye1.style.top=posy1+'px';
    if(!this.minimapTimeout)this.minimapTimeout=window.setTimeout(this.appendMiniMap.bind(this),1000);
}
}
,minimaparea_mouseup:function(evt)
{
this.CenterX=Math.floor((this.minimapeye.offsetLeft+this.minimapeye.offsetWidth/2-this.minimap1.offsetLeft)*this.minimapSize);
this.CenterY=Math.floor((this.minimapeye.offsetTop+this.minimapeye.offsetHeight/2-this.minimap1.offsetTop)*this.minimapSize);
this.setMapPosS(this.CenterX,this.CenterY,null,this.setMap.bind(this));
this.setMiniMapPosS(this.CenterX,this.CenterY);
if(this.minimaptimer)
{
    window.clearInterval(this.minimaptimer);
    this.minimaptimer=null;
}
this.minimapeye1.style.left='80px';
this.minimapeye1.style.top='60px';
if(brw=='ie') this.minimap.releaseCapture();
document.onmousemove=this.doc_mousemove.bindAsEventListener(this);
document.onmouseup=this.doc_mouseup.bindAsEventListener(this);
this.minimapeyedrag=false;
}
,minimaparea_mouseup2:function(evt)
{
this.CenterX=Math.floor((this.minimap.offsetWidth/2-this.minimap1.offsetLeft)*this.minimapSize);
this.CenterY=Math.floor((this.minimap.offsetHeight/2-this.minimap1.offsetTop)*this.minimapSize);
this.setS(this.minimapeye1,
{
    x:80,y:60
}
);
this.setMapPosS(this.CenterX,this.CenterY,null,this.setMap.bind(this));
if(brw=='ie') this.minimap.releaseCapture();
document.onmousemove=this.doc_mousemove.bindAsEventListener(this);
document.onmouseup=this.doc_mouseup.bindAsEventListener(this);
this.minimapdrag=false;
}
,setS:function(elm,obj)
{
var lx=Math.floor(elm.offsetLeft-obj.x);
var ly=Math.floor(elm.offsetTop-obj.y);
var sx=Math.floor(lx/10);
var sy=Math.floor(ly/10);
var px=Math.abs(lx%10);
var py=Math.abs(ly%10);
if(px!=0)sx=(sx<0)?sx:sx+1;
if(py!=0)sy=(sy<0)?sy:sy+1;
var stepnum=0;
var mytimer=window.setInterval(fun.bind(this),10);
function fun()
{
    if(stepnum++==10)
    {
        window.clearInterval(mytimer);
        mytimer=null;
        return;
    }
    if(px!=0&&stepnum==px+1)sx=(sx<0)?sx+1:sx-1;
    if(py!=0&&stepnum==py+1)sy=(sy<0)?sy+1:sy-1;
    elm.style.left=(elm.offsetLeft-sx)+'px';
    elm.style.top=(elm.offsetTop-sy)+'px';
}
}
,setMiniMapPosS:function(x,y)
{
return;
if(this.minimapSlowMoveTimer)window.clearInterval(this.minimapSlowMoveTimer);
if(!x) x=this.CenterX;
if(!y) y=this.CenterY;
var lx=Math.floor(x/this.minimapSize+this.minimap1.offsetLeft-this.minimap.offsetWidth/2);
var ly=Math.floor(y/this.minimapSize+this.minimap1.offsetTop-this.minimap.offsetHeight/2);
lx=(lx==-1)?0:lx;
ly=(ly==-1)?0:ly;
var step=10;
var sx=Math.floor(lx/step);
var sy=Math.floor(ly/step);
var px=Math.abs(lx%step);
var py=Math.abs(ly%step);
if(px!=0)sx=(sx<0)?sx:sx+1;
if(py!=0)sy=(sy<0)?sy:sy+1;
var stepnum=0;
this.minimapSlowMoveTimer=window.setInterval(fun.bind(this),10);
function fun()
{
    if(stepnum++==step)
    {
        window.clearInterval(this.minimapSlowMoveTimer);
        this.minimapSlowMoveTimer=null;
        return;
    }
    if(px!=0&&stepnum==px+1)sx=(sx<0)?sx+1:sx-1;
    if(py!=0&&stepnum==py+1)sy=(sy<0)?sy+1:sy-1;
    this.minimap1.style.left=(this.minimap1.offsetLeft-sx)+'px';
    this.minimap1.style.top=(this.minimap1.offsetTop-sy)+'px';
    this.minimapeye.style.left=(this.minimapeye.offsetLeft-sx)+'px';
    this.minimapeye.style.top=(this.minimapeye.offsetTop-sy)+'px';
}
}
,setMapPosS:function(x,y,onmove,onend)
{
if(this.slowMoveTimer)window.clearInterval(this.slowMoveTimer);
this.hiddenOcInfo();
if(!x||typeof(x)!='number') return;
if(!y||typeof(y)!='number') return;
this.CenterX=x;
this.CenterY=y;
var step=10;
var lx=Math.floor(x-(this.mapWidth/2-this.mapdiv.offsetLeft));
var ly=Math.floor(y-(this.mapHeight/2-this.mapdiv.offsetTop));
lx=(lx==-1)?0:lx;
ly=(ly==-1)?0:ly;
var sx=Math.floor(lx/step);
var sy=Math.floor(ly/step);
var px=Math.abs(lx%step);
var py=Math.abs(ly%step);
if(px!=0)sx=(sx<0)?sx:sx+1;
if(py!=0)sy=(sy<0)?sy:sy+1;
var stepnum=0;
this.noMouseXml=true;
this.slowMoveTimer=window.setInterval(fun.bind(this),10);
function fun()
{
    if(px!=0&&stepnum==px)sx=(sx<0)?sx+1:sx-1;
    if(py!=0&&stepnum==py)sy=(sy<0)?sy+1:sy-1;
    var targetX=this.mapdiv.offsetLeft-sx;
    var targetY=this.mapdiv.offsetTop-sy;
    this.mapdiv.style.left=targetX+'px';
    this.mapdiv.style.top=targetY+'px';
    this.mapdiv2.style.left=-targetX+'px';
    this.mapdiv2.style.top=-targetY+'px';
    if(onmove) onmove(Math.floor(this.mapWidth/2-targetX),Math.floor(this.mapHeight/2-targetY));
    if(stepnum++==step-1)
    {
        window.clearInterval(this.slowMoveTimer);
        this.slowMoveTimer==null;
        this.noMouseXml=false;
        if(onend) setTimeout(onend,100);
    }
}
}
,scrollMap:function(sx,sy)
{
if(sx||sy)
{
    if(!this.keyMoveTimer) this.keyMoveTimer=window.setInterval(fun.bind(this),10);
    else return;
}
else
{
    window.clearInterval(this.keyMoveTimer);
    this.keyMoveTimer=null;
    this.setMap();
}
this.hiddenOcInfo();
function fun()
{
    var targetX=this.mapdiv.offsetLeft-sx;
    var targetY=this.mapdiv.offsetTop-sy;
    this.CenterX+=sx;
    this.CenterY+=sy;
    this.mapdiv.style.left=targetX+'px';
    this.mapdiv.style.top=targetY+'px';
    this.mapdiv2.style.left=-targetX+'px';
    this.mapdiv2.style.top=-targetY+'px';
    this.setMiniMapPos();
}
}
,gotoCenter:function()
{
this.hiddenOcInfo();
this.go2xy(this.defValue.x,this.defValue.y);
}
,scroll:function(x,y)
{
this.hiddenOcInfo();
this.setMapPosS(this.CenterX+x,this.CenterY+y,this.setMiniMapPos.bind(this),onend.bind(this));
function onend()
{
    this.setMap();
}
}
,mousemoveall:function(evt,fun)
{
var evtx=evt.clientX;
var evty=evt.clientY;
var left=10;
var top=10;
var right=this.mapWidth;
var bottom=this.mapHeight;
if(evtx<left || evtx>right || evty<top || evty>bottom)
{
    fun();
}
}
,loadMiniMap:function()
{
return;
var minimapWidth=200,minimapHeight=150;
var startX=Math.floor(this.CenterX/this.minimapSize-minimapWidth/2);
var startY=Math.floor(this.CenterY/this.minimapSize-minimapHeight/2);
var endX=startX+minimapWidth;
var endY=startY+minimapHeight;
var i=0;
for(var y=Math.floor(startY/256);y<=Math.floor(endY/256);y++)
{
    for(var x=Math.floor(startX/256);x<=Math.floor(endX/256);x++)
    {
        if(document.getElementById('m'+this.Zoom+','+x+','+y)) continue;
        this.minimap1.appendChild(this.loadpic(x,y,this.Zoom,4));
    }
}
var delid=[];
for(var i=0;i<this.minimap1.getElementsByTagName('img').length;i++)
{
    var elm=this.minimap1.getElementsByTagName('img')[i];
    if(elm.offsetLeft+256<startX||elm.offsetTop+256<startY||elm.offsetLeft>endX||elm.offsetTop>endY)
    {
        delid.push(elm.id);
    }
}
for(var i=0;i<delid.length;i++)
{
    var elm=document.getElementById(delid[i]);
    if(elm)elm.parentNode.removeChild(elm);
}
}
,loadMap:function()
{
this.startX=Math.floor(this.CenterX-this.mapWidth/2);
this.startY=Math.floor(this.CenterY-this.mapHeight/2);
this.endX=this.startX+this.mapWidth;
this.endY=this.startY+this.mapHeight;
var i=0;
for(var y=Math.floor(this.startY/256);y<=Math.floor(this.endY/256);y++)
{
    for(var x=Math.floor(this.startX/256);x<=Math.floor(this.endX/256);x++)
    {
        this.curID[i++]=x+','+y;
        if($(this.mapType+','+this.Zoom+','+x+','+y)) continue;
        this.mapdiv1.appendChild(this.loadpic(x,y,this.Zoom,this.mapType));
    }
}
this.curID.length=i;
this.clrEx();
if(this.onMapComplete&&!this.mapCompleteTimer)this.mapCompleteTimer=window.setInterval(this.threadFun1.bind(this),500);
}
,clrMapCompleteTimer:function()
{
if(this.mapCompleteTimer)
{
    window.clearInterval(this.mapCompleteTimer);
    this.mapCompleteTimer=null;
}
if(this.onMapComplete)
{
    this.onMapComplete();
    this.onMapComplete=null;
}
}
,threadFun1:function()
{
var elm;
for(var i=0;i<this.curID.length;i++)
{
    elm=$(this.mapType+','+this.Zoom+','+this.curID[i]);
    if(elm&&elm.readyState!='complete')
    {
        return;
    }
}
window.clearInterval(this.mapCompleteTimer);
this.mapCompleteTimer=null;
if(this.onMapComplete)
{
    this.onMapComplete();
    this.onMapComplete=null;
}
}
,createRelativeDiv:function()
{
var targetZ=3;
var wh=this.zoomvalue(this.Zoom,256,targetZ);
var delid=[];
for(var i=0;i<this.mapdiv32.getElementsByTagName('div').length;i++)
{
    var elm=this.mapdiv32.getElementsByTagName('div')[i];
    if(elm.id.substring(0,2)!='r'+targetZ) continue;
    if(elm.offsetLeft+wh<this.startX||elm.offsetTop+wh<this.startY||elm.offsetLeft>this.endX||elm.offsetTop>this.endY)
    {
        delid.push(elm.id);
    }
}
for(var i=0;i<delid.length;i++)
{
    var elm=$(delid[i]);
    if(elm)elm.parentNode.removeChild(elm);
}
for(var y=Math.floor(this.startY/wh);y<=Math.floor(this.endY/wh);y++)
{
    for(var x=Math.floor(this.startX/wh);x<=Math.floor(this.endX/wh);x++)
    {
        if($('r'+targetZ+''+this.Zoom+','+x+','+y)) continue;
        this.mapdiv32.appendChild(this.createDiv('r'+targetZ+''+this.Zoom+','+x+','+y,x*wh,y*wh,0,0,2));
    }
}
}
,setGlobalPopPos:function()
{
for(var i=0;i<this.globalPop.length;i++)
{
    var elm=$(this.globalPop[i]);
    if(elm)
    {
        elm.style.left=(this.getXY(elm.style.x0)-elm.style.sx)+'px';
        elm.style.top=(this.getXY(elm.style.y0)-elm.style.sy)+'px';
    }
}
}
,setMapPos:function(x,y)
{
if(x!=null&&typeof(x)=='number') this.CenterX=x;
if(y!=null&&typeof(y)=='number') this.CenterY=y;
if(!this.CenterX) this.CenterX=Math.floor(this.mapdiv.offsetLeft+this.mapWidth/2);
if(!this.CenterY) this.CenterY=Math.floor(this.mapdiv.offsetTop+this.mapHeight/2);
var posx=Math.floor(this.mapWidth/2-this.CenterX);
var posy=Math.floor(this.mapHeight/2-this.CenterY);
this.mapdiv.style.left=posx+'px';
this.mapdiv.style.top=posy+'px';
this.mapdiv2.style.left=-posx+'px';
this.mapdiv2.style.top=-posy+'px';
this.setMiniMapPos();
}
,setMiniMapPos:function(x,y)
{
return;
if(!this.isLoadMiniMap) return;
if(!x) x=this.CenterX;
if(!y) y=this.CenterY;
var minimapWidth=200,minimapHeight=150;
var startX=Math.floor(x/this.minimapSize-minimapWidth/2);
var startY=Math.floor(y/this.minimapSize-minimapHeight/2);
this.minimap1.style.left=-startX+'px';
this.minimap1.style.top=-startY+'px';
}
,createHsMap:function()
{
this.divhs=this.mapdiv2.appendChild(this.createDiv('map_divhs',0,0,1000,800,5));
if(brw=='ie')
{
    this.imghs=this.divhs.appendChild(document.createElement('<img src="'+this.apiPath+'/images/hotspot.gif" id="map_imghs" usemap="#map_maphs" border="0">'));
    this.maphs=this.divhs.appendChild(document.createElement('<map id="map_maphs" name="map_maphs"></map>'));
}
else
{
    this.imghs=this.divhs.appendChild(document.createElement('img'));
    this.imghs.setAttribute('id','map_imghs');
    this.imghs.setAttribute('src',this.apiPath+'/images/hotspot.gif');
    this.imghs.setAttribute('border','0');
    this.imghs.setAttribute('usemap','#map_maphs');
    this.maphs=this.divhs.appendChild(document.createElement('map'));
    this.maphs.setAttribute('name','map_maphs');
}
}
,loadHs:function()
{
this.loadCurXml();
function showhs()
{
    for(var i=0;i<this.hsdata.length;i++)
    {
        var hs=this.hsdata[i];
        var area=this.maphs.childNodes[i];
        if(!area) area=document.createElement('area');
        area.shape='poly';
        area.coords=hs.coords;
        area.href='#';
        area.alt=hs.name;
        area._x=hs.x;
        area._y=hs.y;
        area.onclick=function()
        {
            return false;
        };
        area.onfocus=function()
        {
            this.blur();
        };
        if(area.parentNode!=this.maphs) this.maphs.appendChild(area);
    }
}
}
,createHsArea:function(obj)
{
var area=document.createElement('area');
area.shape='poly';
area.coords=obj.coords;
area.href='#';
area._name=obj.name;
area._id=obj.id;
area._x=obj.x;
area._y=obj.y;
area._xs=obj.xs;
area._ys=obj.ys;
area.onclick=function()
{
    return false;
}
.bindAsEventListener(this);
area.onfocus=function(evt)
{
    var src=evt.srcElement||evt.target;
    src.blur();
}
.bindAsEventListener(this);
area.onmousemove=this.area_mousemove.bindAsEventListener(this);
area.onmouseout=this.area_mouseout.bindAsEventListener(this);
this.maphs.appendChild(area);
}
,area_mousemove:function(evt)
{
var src=evt.srcElement||evt.target;
var ex=evt.clientX;
var ey=evt.clientY;
this.mapAreaInfoTip.style.left=ex+'px';
this.mapAreaInfoTip.style.top=(ey-25)+'px';
if(this.mapAreaInfoTip.style.display=='none'&&src._name!='')
{
    this.mapAreaInfoTip.innerHTML=src._name;
    this.mapAreaInfoTip.style.display='';
}
}
,area_mouseout:function(evt)
{
this.hiddenAreaInfoTip();
}
,area_dblclick:function(evt)
{
var src=evt.srcElement?evt.srcElement:evt.target;
this.mdHsArea(evt,src);
}
,hiddenAreaInfoTip:function()
{
this.mapAreaInfoTip.style.display='none';
}
,drawLine:function(o)
{
if($('div_p_hs_line'+o.id))return;
var arrX=o.xs.split(',');
var arrY=o.ys.split(',');
var x=o.x;
var y=o.y;
var strokecolor='#00FF00';
var strokeweight=1.2;
if(o.strokecolor) strokecolor=o.strokecolor;
if(o.strokeweight) strokeweight=o.strokeweight;
var option=new vOption();
option.strokecolor=strokecolor;
option.strokeweight=strokeweight;
if(o.startarrow) option.startarrow=o.startarrow;
if(o.endarrow) option.endarrow=o.endarrow;
var p_hs=$(this.createPop('div_p_hs_line'+o.id,'',x,y,0,0,5));
if(!p_hs) return;
var p=new vPolyline('p_hs_line'+o.id,p_hs,arrX,arrY,option);
p.setZoom(1/Math.pow(2,this.Zoom-1));
p.setShift(x,y);
p.drawPolyline();
var curP=
{
    parent:p_hs,p:p
};
if(o.autoZoom)this.p_hs['line'+o.id]=curP;
p_hs=null;
p=null;
return curP;
}
,destroyAllG:function()
{
this.curP=null;
for(var item in this.p_hs)
{
    if(item!='list')
    {
        this.destroyG(item);
    }
}
}
,destroyG:function(item)
{
this.p_hs[item].parent.innerHTML='';
this.p_hs[item].parent.parentNode.removeChild(this.p_hs[item].parent);
this.p_hs[item]=null;
delete this.p_hs[item];
}
,lineZoom:function()
{
for(var item in this.p_hs)
{
    if(item!='list'&&this.p_hs[item].p)
    {
        this.p_hs[item].p.setZoom(1/Math.pow(2,this.Zoom-1));
        this.p_hs[item].p.paint();
    }
}
}
,invokeFun:function(argu)
{
var method=argu[0];
argu = Array.prototype.slice.call(argu,1);
if(typeof this[method]!='function') return null;
return this[method].bind(this).apply(null,argu);
}
,loadCurXml:function()
{
var startX=Math.floor(this.CenterX-this.mapWidth/2);
var startY=Math.floor(this.CenterY-this.mapHeight/2);
var endX=startX+this.mapWidth;
var endY=startY+this.mapHeight;
startX=this.zoomvalue(this.hsLoadLevel,startX);
startY=this.zoomvalue(this.hsLoadLevel,startY);
endX=this.zoomvalue(this.hsLoadLevel,endX);
endY=this.zoomvalue(this.hsLoadLevel,endY);
for(var y=Math.floor(startY/256);y<=Math.floor(endY/256);y++)
{
    for(var x=Math.floor(startX/256);x<=Math.floor(endX/256);x++)
    {
        this.loadJs(x,y,this.hsLoadLevel);
    }
}
}
,loadXml:function(x,y,z)
{
if(!this.isLoadHotspot||this.mapType!=3) return;
var id=z+','+x+','+y;
var ext='';
if(this.type==1) ext='?time='+new Date().getTime();
var url=this.resourcePath+'xml/info/'+z+'/'+Math.floor(x/10)+'/'+x+','+y+'.xml'+ext;
var url2=this.hsPath+z+'/'+Math.floor(x/10)+'/'+x+','+y+this.localeExt+'.js'+ext;
var url3=this.resourcePage+'x='+x+'&y='+y+'&z='+z;
if(this.areaData[id])
{
    this.parseHsData(x,y,z);
}
else if(this.hsLoadType=='xml')this.loadXML2(url,doXml.bind(this),true);
else if(this.hsLoadType=='text')this.loadXML2(url2,doText.bind(this));
function doXml(xmlElm)
{
    var startX=Math.floor(this.CenterX-this.mapWidth/2);
    var startY=Math.floor(this.CenterY-this.mapHeight/2);
    if(xmlElm)
    {
        var areaList=[];
        var areas=xmlElm.getElementsByTagName('area');
        for(var i=0;i<areas.length;i++)
        {
            var area=
            {
            };
            area.id=areas[i].getElementsByTagName('id')[0].firstChild.nodeValue;
            area.name=areas[i].getElementsByTagName('name')[0].firstChild.nodeValue;
            area.x=areas[i].getElementsByTagName('xo')[0].firstChild.nodeValue;
            area.y=areas[i].getElementsByTagName('yo')[0].firstChild.nodeValue;
            area.xs=areas[i].getElementsByTagName('xs')[0].firstChild.nodeValue;
            area.ys=areas[i].getElementsByTagName('ys')[0].firstChild.nodeValue;
            areaList.push(area);
            if(!this.hsAreaFlag[area.id])
            {
                var sxs=area.xs.split(',');
                var sys=area.ys.split(',');
                var coords=(this.zoomvalue(this.Zoom,parseInt(sxs[1]),z)-startX)+','+(this.zoomvalue(this.Zoom,parseInt(sys[1]),z)-startY);
                for(var j=2;j<sxs.length;j++)coords+=','+(this.zoomvalue(this.Zoom,parseInt(sxs[j]),z)-startX)+','+(this.zoomvalue(this.Zoom,parseInt(sys[j]),z)-startY);
                var o=
                {
                };
                o=area;
                o.coords=coords;
                this.hsAreaFlag[area.id]=true;
                this.createHsArea(o);
            }
        }
        this.areaData[id]=areaList;
    }
    xmlElm=null;
    delete(xmlElm);
}
function doText(data)
{
    if(!data) return;
    var dataArr=data.split('|');
    this.areaData[id]=eval(dataArr[1]);
    this.parseHsData(x,y,z);
}
}
,parseHsData:function(x,y,z)
{
var areas=this.areaData[z+','+x+','+y];
if(!areas) return;
for(var i=0;i<areas.length;i++)
{
    var area=areas[i];
    if(!this.hsAreaFlag[area.id])
    {
        var sxs=area.xs.split(',');
        var sys=area.ys.split(',');
        var coords=(this.zoomvalue(this.Zoom,parseInt(sxs[1]),1)-this.startX)+','+(this.zoomvalue(this.Zoom,parseInt(sys[1]),1)-this.startY);
        for(var j=2;j<sxs.length;j++)coords+=','+(this.zoomvalue(this.Zoom,parseInt(sxs[j]),1)-this.startX)+','+(this.zoomvalue(this.Zoom,parseInt(sys[j]),1)-this.startY);
        var o=
        {
        };
        o=area;
        o.coords=coords;
        this.hsAreaFlag[area.id]=true;
        this.createHsArea(o);
    }
}
}
,separateObj:function(parent)
{
if(!parent) return;
for(var i=0;i<parent.childNodes.length;i++)
{
    var child=parent.childNodes[i];
    if(child._node)
    {
        this.objs[child._node].push(child);
    }
}
}
,svObj:function(elm)
{
if(elm._node)
{
    this.objs[elm._node].push(elm);
}
}
,createImg:function(src,w,h)
{
var elm=null;
if(brw=='ie'&&src.indexOf('.png')!=-1)
{
    elm=document.createElement('div');
    elm.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+src+',sizingMethod=scale)';
}
else
{
    elm=document.createElement('img');
    elm.src=src;
}
elm.style.width=w+'px';
elm.style.height=h+'px';
return elm;
}
,showStationBlog:function(id,name,x,y)
{
if(this.moved>3)return;
var sx=180*Math.pow(2,this.Zoom-1);
var sy=20*Math.pow(2,this.Zoom-1);
var htmlStr='<div style="position:absolute;left:-67px;top:153px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="24px" height="24px"> <param name="movie" value="/images/flash/kkk.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="api/images/kkk.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="24px" height="24px"></embed></object></div><div style="position:absolute;left:-53px;top:129px;"><img src="images/map/point2.gif"></div><img border="0" style="position:absolute;left:310px;top:6px;cursor:pointer" src="/images/map/close.gif" onclick="mapApi.removePop(\'pop_bus\')"><div id="Layer1"><div style="background:#fff;padding:1 0 0 1;width:332;height:230;"><div style="height:100%; width:100%; "><div style="background:#fff;height:100%; width:100%;"><iframe src="'+this.blogPath+'busstation.jspa?locale='+this.locale+'&id={@ID}" height="100%" width="100%" frameborder="0" scrolling="no" ></iframe></div></div></div></div>';
htmlStr=htmlStr.replace('{@ID}',id);
this.AreaUnitInfo={};
this.AreaUnitInfo.AreaID=id;
this.AreaUnitInfo.AreaName=name;
this.AreaUnitInfo.x=x;
this.AreaUnitInfo.y=y;
this.AreaUnitInfo.type=3;
this.removePop('pop_bus');
this.go2xyS(parseInt(x)+sx,parseInt(y)-sy);
this.createPop('pop_bus',htmlStr,x,y,-55,165,7,this.infoLoadLevel);
}
,loadInfo:function()
{
if(!this.isLoadInfo||this.Zoom>this.infoViewLevel||this.mapType!=3) return;
var targetZ=this.infoLoadLevel;
var wh=this.zoomvalue(this.Zoom,256,targetZ);
this.infoState.ready('info');
for(var y=Math.floor(this.startY/wh);y<=Math.floor(this.endY/wh);y++)
{
    for(var x=Math.floor(this.startX/wh);x<=Math.floor(this.endX/wh);x++)
    {
        var id='r'+this.infoLoadLevel+this.Zoom+','+x+','+y;
        if(this.infoState.getState(id)) continue;
        this.parseUserPopData(x,y,this.infoLoadLevel);
        this.parseInfo(x,y,this.infoLoadLevel);
    }
}
this.infoState.clear('info');
}
,infoIsLoad:function(x,y)
{
for(var i=0;i<this.infoFlag.length;i++)
{
    if(this.infoFlag[i].x==x&&this.infoFlag[i].y==y)return true;
}
return false;
}
,parseInfo:function(x,y,z)
{
var id=z+','+x+','+y;
var ext='';
if(this.type==1) ext='?time='+new Date().getTime();
var url=this.resourcePath+'xml/info/'+z+'/'+Math.floor(x/10)+'/'+x+','+y+'.xml'+ext;
var url2=this.hsPath+z+'/'+Math.floor(x/10)+'/'+x+','+y+this.localeExt+'.js'+ext;
var url3=this.resourcePage+'x='+x+'&y='+y+'&z='+z;
if(!this.createSign(id))
{
    if(this.infoLoadType=='xml')this.loadXML2(url,doXml.bind(this),true);
    else this.loadXML2(url2,doText.bind(this));
}
function doXml(xmlElm)
{
    if(xmlElm)
    {
        if(this.isLoadBusStation&&!this.busStationData[id])
        {
            var htmlStr;
            var bsList=xmlElm.getElementsByTagName('busStation');
            var bsArr=[];
            for(var i=0;i<bsList.length;i++)
            {
                var bs=
                {
                };
                bs.id=bsList[i].getElementsByTagName('id')[0].firstChild.nodeValue;
                bs.name=bsList[i].getElementsByTagName('name')[0].firstChild.nodeValue;
                bs.x=this.zoomvalue(1,bsList[i].getElementsByTagName('xo')[0].firstChild.nodeValue,z);
                bs.y=this.zoomvalue(1,bsList[i].getElementsByTagName('yo')[0].firstChild.nodeValue,z);
                bsArr.push(bs);
            }
            this.busStationData[id]=bsArr;
        }
        if(this.isLoadAd)
        {
            var adList=xmlElm.getElementsByTagName('ad');
            var adArr=[];
            for(var i=0;i<adList.length;i++)
            {
                var ad=
                {
                };
                ad.id=adList[i].getElementsByTagName('id')[0].firstChild.nodeValue;
                ad.name=adList[i].getElementsByTagName('name')[0].firstChild.nodeValue;
                ad.src=adList[i].getElementsByTagName('src')[0].firstChild.nodeValue;
                ad.type=adList[i].getElementsByTagName('type')[0].firstChild.nodeValue;
                ad.x=adList[i].getElementsByTagName('xo')[0].firstChild.nodeValue;
                ad.y=adList[i].getElementsByTagName('yo')[0].firstChild.nodeValue;
                ad.z=adList[i].getElementsByTagName('z')[0].firstChild.nodeValue;
                ad.w=adList[i].getElementsByTagName('width')[0].firstChild.nodeValue;
                ad.h=adList[i].getElementsByTagName('height')[0].firstChild.nodeValue;
                ad.url=adList[i].getElementsByTagName('url')[0].firstChild.nodeValue;
                ad.date=adList[i].getElementsByTagName('date')[0].firstChild.nodeValue;
                adArr.push(ad);
            }
            this.adData[id]=adArr;
        }
        this.createSign(id);
        xmlElm=null;
        delete(xmlElm);
    }
}
function doText(data)
{
    var dataArr=data.split('|');
    this.busStationData[id]=eval(dataArr[3]);
    var adFlag=parseInt(dataArr[0]);
    if(adFlag&&this.isLoadAd)this.parseAd(id);
    this.createSign(id);
}
}
,isExpire:function(d)
{
var date=new Date();
if(d.getTime()<date.getTime())return true;
return false;
}
,parseAd:function(id)
{
var arr=id.split(',');
var x=arr[1];
var y=arr[2];
var z=arr[0];
var url=this.hsPath+z+'/'+Math.floor(x/10)+'/'+x+','+y+'_ad.js';
this.loadXML2(url,doAdText.bind(this));
function doAdText(data)
{
    this.adData[id]=eval(data);
    this.createAd(id);
}
}
,createAd:function(id)
{
var adArr=this.adData[id];
for(var i=0;i<adArr.length;i++)
{
    var ad=adArr[i];
    if(true)
    {
        if(ad.type==1||ad.type=='vr_1')
        {
            if(this.Zoom>3) continue;
            if(this.type!=1)
            {
                ad.type='vr_1';
                var args=ad.url+','+ad.w+','+ad.h;
                this.createUserPop(ad,
                {
                    args:args
                }
                );
            }
            else
            {
                var htmlStr='<img src="'+this.apiPath+'/images/skin2/icon/vr_1.gif" alt="'+ad.name+'" onclick="mapApi.invokeParentFun(\'editAd\','+ad.id+')" style="cursor:pointer;">';
                htmlStr=''
                this.createPopT('osd'+ad.id,htmlStr,ad.x,ad.y,15,36,5,this.infoLoadLevel);
            }
        }
        else if(ad.type==2||ad.type==7)
        {
            if(this.type!=1)
            {
                var htmlStr='<object _ad=1 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="!{Width}" height="!{Height}"> <param name="movie" value="!{Src}"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="!{Src}" width="!{Width}" height="!{Height}" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
                var src='';
                if(ad.type==2) src=this.filePath+ad.src;
                else src=this.filePath+ad.src+'&title='+ad.name;
                htmlStr=htmlStr.replace(/!{Src}/g,src);
                htmlStr=htmlStr.replace(/!{Width}/g,ad.w/Math.pow(2,this.Zoom-1));
                htmlStr=htmlStr.replace(/!{Height}/g,ad.h/Math.pow(2,this.Zoom-1));
                this.createPopT('osd'+ad.id,htmlStr,ad.x,ad.y,ad.w/(2*Math.pow(2,this.Zoom-1)),ad.h/(2*Math.pow(2,this.Zoom-1)),5,this.infoLoadLevel);
            }
            else
            {
                var htmlStr='<img src="'+this.apiPath+'/images/swf.gif" alt="'+ad.name+'" style="cursor:pointer" onclick="mapApi.invokeParentFun(\'editAd\','+ad.id+')">';
                this.createPopT('osd'+ad.id,htmlStr,ad.x,ad.y,0,0,5,this.infoLoadLevel);
            }
        }
        else
        {
            var htmlStr='';
            var src=this.filePath+ad.src;
            var w=ad.w/Math.pow(2,this.Zoom-1);
            var h=ad.h/Math.pow(2,this.Zoom-1);
            if(this.type!=1)
            {
                if(brw=='ie'&&src.indexOf('png')!=-1)
                {
                    htmlStr='<div _ad=1 width='+w+'px height='+h+'px style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+src+',sizingMethod=scale);width:'+w+'px;height:'+h+'px;cursor:pointer;" onclick="mapApi.openwin(\''+ad.url+'\')"></div>';
                }
                else
                {
                    htmlStr='<img _ad=1 src="'+src+'" width='+w+'px height='+h+'px style="width:'+w+'px;height:'+h+'px;cursor:pointer" onclick="mapApi.openwin(\''+ad.url+'\')">';
                }
            }
            else
            {
                htmlStr='<img src="'+this.apiPath+'/images/pic.gif" alt="'+ad.name+'" style="cursor:pointer" onclick="mapApi.invokeParentFun(\'editAd\','+ad.id+')">';
            }
            this.createPopT('osd'+ad.id,htmlStr,ad.x,ad.y,ad.w/(2*Math.pow(2,this.Zoom-1)),ad.h/(2*Math.pow(2,this.Zoom-1)),5,this.infoLoadLevel);
        }
    }
}
}
,createSign:function(id)
{
if(this.isLoadBusStation)
{
    if(this.busStationData[id])
    {
        var busStationArr=this.busStationData[id];
        for(var i=0;i<busStationArr.length;i++)
        {
            if(this.type!=1)
            {
                busStationArr[i].type='bs_1';
                this.createUserPop(busStationArr[i]);
            }
            else
            {
                var str='id="bus'+busStationArr[i].id+'" _id='+busStationArr[i].id+' _name="'+busStationArr[i].name+'" _x='+busStationArr[i].x+' _y='+busStationArr[i].y+' title="'+busStationArr[i].name+'"';
                htmlStr='<img src="'+this.apiPath+'/images/skin2/bus.gif" '+str+' style="cursor:pointer">';
                htmlStr=''
                this.createPopT('busStation'+busStationArr[i].id,htmlStr,busStationArr[i].x,busStationArr[i].y,15,36,5,this.infoLoadLevel);
            }
        }
    }
}
if(this.isLoadAd)
{
    if(this.adData[id])
    {
        this.createAd(id);
    }
}
if(this.busStationData[id])return true;
else return false;
}
,loadSign:function(type)
{
var targetZ=this.infoLoadLevel;
var wh=this.zoomvalue(this.Zoom,256,targetZ);
switch(type)
{
    case 'BusStation':this.isLoadBusStation=true;
    break;
    case 'Metro':this.isLoadMetro=true;
    break;
    case 'All':this.isLoadBusStation=true;
    this.isLoadMetro=true;
    break;
    default:return;
    break;
}
if(!this.isLoadInfo||this.Zoom>this.infoViewLevel||this.mapType!=3) return;
for(var y=Math.floor(this.startY/wh);y<=Math.floor(this.endY/wh);y++)
{
    for(var x=Math.floor(this.startX/wh);x<=Math.floor(this.endX/wh);x++)
    {
        this.parseInfo(x,y,targetZ);
    }
}
}
,removeSign:function(type)
{
var targetZ=this.infoLoadLevel;
var delid=[];
var flag='';
switch(type)
{
    case 'BusStation':flag='busStation';
    this.isLoadBusStation=false;
    break;
    case 'Metro':flag='metro';
    this.isLoadMetro=false;
    break;
    default:return;
    break;
}
for(var i=0;i<this.mapdiv31.getElementsByTagName('div').length;i++)
{
    var elm=this.mapdiv31.getElementsByTagName('div')[i];
    if(elm.id.substring(0,10)!=flag) continue;
    delid.push(elm.id);
}
for(var i=0;i<delid.length;i++)
{
    var elm=$(delid[i]);
    if(elm)
    {
        if(elm._node)this.objs[elm._node].push(elm);
        elm.parentNode.removeChild(elm);
    }
}
}
,findStation:function(x,y,f)
{
x=Math.floor(x/2048);
y=Math.floor(y/2048);
var url=this.resourcePage+'x='+x+'&y='+y+'&z=4';
var stations=[];
this.loadXML2(url,fun);
function fun(value)
{
    if(value)
    {
        stations=eval(value.split('|')[1]);
    }
    if(typeof f=='function')
    {
        if(stations.length!=0)f(true);
        else f(false);
    }
}
}
,loadXML:function(url,fun)
{
var xmlDoc;
if (window.ActiveXObject)
{
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=true;
    xmlDoc.load(url);
    xmlDoc.onreadystatechange=doxml_ie;
}
else if (document.implementation &&document.implementation.createDocument)
{
    xmlDoc= document.implementation.createDocument("","",null);
    try
    {
        xmlDoc.load(url);
        xmlDoc.onload=doxml;
    }
    catch(e)
    {
    }
}
else
{
    alert('load xml error!');
}
function doxml_ie()
{
    if(xmlDoc.readyState!=4)
    {
        return;
    }
    if(xmlDoc.documentElement&&xmlDoc.parseError.errorCode==0)
    {
        fun(xmlDoc.documentElement);
        xmlDoc.onreadystatechange=function()
        {
        };
        xmlDoc.abort();
        xmlDoc=null;
        delete(xmlDoc);
    }
    else
    {
        xmlDoc.onreadystatechange=function()
        {
        };
        xmlDoc.abort();
        xmlDoc=null;
        delete(xmlDoc);
    }
}
function doxml()
{
    fun(xmlDoc.documentElement);
}
}
,loadXML2:function(url,fun,isXML)
{
var xmlObj = null;
if(window.XMLHttpRequest)
{
    xmlObj = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
    xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
    return;
}
xmlObj.onreadystatechange = doxml.bind(this);
xmlObj.open ('GET', url, true);
try
{
    xmlObj.send ('');
}
catch(e)
{
}
function doxml()
{
    if(xmlObj.readyState!=4)
    {
        return;
    }
    if(xmlObj.status==200)
    {
        if(!isXML) fun(xmlObj.responseText);
        else fun(xmlObj.responseXML);
        xmlObj.onreadystatechange=function()
        {
        };
        xmlObj.abort();
        xmlObj=null;
        delete xmlObj;
    }
    else
    {
        xmlObj.onreadystatechange=function()
        {
        };
        xmlObj.abort();
        xmlObj=null;
        delete xmlObj;
    }
}
}
,loadJs:function(x,y,z)
{
var xmljsid='xmljs'+z+','+x+','+y;
if(!$(xmljsid))
{
    var xmljselm=document.createElement('script');
    xmljselm.language='javascript';
    xmljselm.id=xmljsid;
    xmljselm.src=this.resourcePage+'x='+x+'&y='+y+'&z='+z+'&t=1';
    document.body.appendChild(xmljselm);
}
}
,loadpic:function(x,y,z,d)
{
var elm=document.createElement('img');
if(!z) z=this.Zoom;
elm.id=d+','+z+','+x+','+y;
elm.style.left=x*256+'px';
elm.style.top=y*256+'px';
elm.style.width='256px';
elm.style.height='256px';
elm.style.position='absolute';
if(d==4)elm.src=this.mapPath+d+'/lv'+z+'/'+x+','+y+'.gif';
else elm.src=this.mapPath+d+'/lv'+z+'/'+x+','+y+'.jpg';
return elm;
}
,mapdiv_mousedown:function(evt)
{
}
,doc_mousedown:function(evt)
{
var src=evt.srcElement?evt.srcElement:evt.target;
if(src&&(src.tagName.toLowerCase()=='input'|| src.tagName.toLowerCase() == 'textarea'|| src.tagName.toLowerCase() == 'object'))
{
    this.isText=true;
    return true;
}
this.infoflag=false;
this.ocx=evt.clientX;
this.ocy=evt.clientY;
if(evt.button==(brw=='ie'?1:0))
{
    if(src.id=='map_zbSign')
    {
        this.zoomFlag=true;
        this.bmy=this.ocy-this.zoomBarSign.offsetTop;
        this.bmTop=this.zoomBarSign.offsetTop;
        this.slowZoomBegin();
    }
    else if(!this.wheelTimer)
    {
        this.CenterX1=this.CenterX;
        this.CenterY1=this.CenterY;
        if(brw=='ie') this.mapdiv.setCapture();
        this.drages=true;
    }
}
this.moved=0;
if(src.tagName=='AREA')this.infoflag=true;
this.hiddenAreaInfoTip();
if(this.mymousedown) this.mymousedown(evt);
return false;
}
,doc_mousemove:function(evt)
{
if(this.isText) return;
var ex=evt.clientX;
var ey=evt.clientY;
if(this.zoomFlag)
{
    this.zoomBarSign.style.top=(ey-this.bmy)+'px';
    if(this.zoomBarSign.offsetTop<46) this.zoomBarSign.style.top='46px';
    if(this.zoomBarSign.offsetTop>100) this.zoomBarSign.style.top='100px';
    var zz=Math.pow(2,-(this.zoomBarSign.offsetTop-this.bmTop)/18).toFixed(3);
    this.slowZoom(zz);
}
else if(this.drages)
{
    this.moved++;
    if(this.mapdiv.style.cursor!='move'&&this.moved>=3)
    {
        this.mapdiv.style.cursor='move';
        this.hiddenOcInfo();
    }
    this.setMapPos(this.CenterX1-(ex-this.ocx),this.CenterY1-(ey-this.ocy));
}
else if(!this.noMouseXml&&this.Zoom<=this.hsViewLevel)
{
    var hp1=Math.floor((ex-this.mapdiv.offsetLeft)/this.zoomvalue(this.Zoom,256,this.hsLoadLevel));
    var vp1=Math.floor((ey-this.mapdiv.offsetTop)/this.zoomvalue(this.Zoom,256,this.hsLoadLevel));
    if(!this.hsXmlFlag[this.hsLoadLevel+','+hp1+','+vp1])
    {
        this.loadXml(hp1,vp1,this.hsLoadLevel);
        this.hsXmlFlag[this.hsLoadLevel+','+hp1+','+vp1]=true;
    }
}
if(this.isMapTip)
{
    this.mapTip.style.left=(ex+15)+'px';
    this.mapTip.style.top=(ey+15)+'px';
}
if(this.p2)
{
    this.p2.setPoint(this.getCurX(evt),this.getCurY(evt),true,1);
}
if(this.mymousemove) this.mymousemove(evt);
return false;
}
,doc_mouseup:function(evt)
{
var src=evt.srcElement?evt.srcElement:evt.target;
if(this.zoomFlag)
{
    this.zoomFlag=false;
    var z=Math.round((this.zoomBarSign.offsetTop-46)/18)+1;
    this.slowZoomEnd(z);
    return false;
}
if(this.drages)
{
    this.mapdiv.style.cursor='';
    if(brw=='ie') this.mapdiv.releaseCapture();
    this.setMap();
    if(this.moved>=3)this.hiddenOcInfo();
}
this.drages=false;
if(this.mode==1&&evt.button==1&&this.moved<3)
{
    this.drawPolyline();
}
if(true&&this.mode>100)
{
    if(this.moved<=3&&evt.button==1)
    {
        switch(this.mode)
        {
            case 101:if(this.infoflag) this.drawArea(src);
            else this.drawNewArea(evt);
            break;
            case 102:this.drawPoint(evt);
            this.getPtInfo(evt,src);
            break;
            case 103:case 104:var params=
            {
            };
            this.ptInfo=
            {
            };
            if(src.id.indexOf('bus')!=-1)
            {
                params.x=src._x;
                params.y=src._y;
                var p=this.as2l(params.x,params.y,src._id,src._name);
                if(p)this.getPtInfo(evt,src);
            }
            else
            {
                var p=this.as2l(this.getCurX(evt),this.getCurY(evt));
            }
            if(!p)
            {
                return;
            }
            else
            {
                params.nextId=p.nextId;
            }
            if(this.mode==103||!this.curP)this.drawNewLine(evt,params);
            else this.editLine(evt,params);
            break;
            case 105:var params=
            {
            };
            params.strokeweight=5;
            if(!this.curP)this.drawNewLine(evt,params);
            else this.editLine(evt);
            break;
            case 108:this.getPtInfo(evt,src);
            if(this.infoflag) this.drawArea(src);
            break;
            case 109:if(this.infoflag)
            {
                this.getPtInfo(evt,src);
                this.mdHsArea(evt,src);
            }
            else this.editLine(evt);
            break;
            default:break;
        }
        this.infoflag=false;
        if(this.mymouseup) this.mymouseup(evt);
        return;
    }
}
if(this.mode==1&&evt.button==2) this.endDraw(evt);
if(this.mode==1) return;
if(this.moved<=3&&this.infoflag)
{
    this.AreaUnitInfo=
    {
    };
    this.AreaUnitInfo.AreaID=src._id;
    this.AreaUnitInfo.AreaName=src._name;
    if(evt.button==(brw=='ie'?1:0)&&!this.loadJsData&&this.isShowAUInfo)this.showOCInfo(src._x,src._y,src._id);
    else if(this.myAreaClick)
    {
        this.myAreaClick(evt);
    }
    this.infoflag=false;
}
if(!this.isText)this.mapdiv.focus();
this.isText=false;
if(this.mymouseup) this.mymouseup(evt);
return false;
}
,doc_dblclick:function(evt)
{
}
,endDraw:function(evt)
{
if(this.mode==1)
{
    if(this.p1)
    {
        this.p2.destroy();
        this.p2=null;
        var img=document.createElement('img');
        //img.src=this.apiPath+'/images/skin2/flag.gif';
        img.style.position='absolute';
        img.style.left=0;
        img.style.top=-21;
        this.pObjs[this.pObjs.length-1].appendChild(img);
        alert(this.getDistance()+'m');
        this.p1.destroy();
        this.p1=null;
        this.mode=null;
        for(var i=0;i<this.pObjs.length;i++)
        {
            this.pObjs[i].parentNode.removeChild(this.pObjs[i]);
        }
    }
}
this.setMapTip();
}
,drawPolyline:function(evt)
{
if(this.p1==null)
{
    this.pObjs=[];
    var option=new vOption();
    option.strokecolor='#0000FF';
    option.strokeweight=2;
    this.pObjs[0]=$(this.createPop('pdiv','',this.getCurX(evt),this.getCurY(evt),0,0,5));
    this.p1=new vPolyline('p1',this.pObjs[0],null,null,option);
    this.p1.setZoom(1/Math.pow(2,this.Zoom-1));
    this.p1.setShift(this.getCurX(evt),this.getCurY(evt));
    this.p1.addPoint(this.getCurX(evt),this.getCurY(evt));
    this.p2=new vPolyline('p2',this.pObjs[0],null,null,option);
    this.p2.setZoom(1/Math.pow(2,this.Zoom-1));
    this.p2.setShift(this.getCurX(evt),this.getCurY(evt));
    this.p2.setPoint(this.getCurX(evt),this.getCurY(evt));
    var img=document.createElement('img');
    //img.src=this.apiPath+'/images/skin2/flag.gif';
    img.style.position='absolute';
    img.style.left=0;
    img.style.top=-21;
    this.pObjs[this.pObjs.length-1].appendChild(img);
    if(this.p1!=null)
    {
        this.p1.drawPolyline();
        this.p2.drawPolyline();
    }
}
else
{
    this.p1.addPoint(this.getCurX(evt),this.getCurY(evt),true);
    this.p2.setPoint(this.getCurX(evt),this.getCurY(evt),null,0);
    this.pObjs[this.pObjs.length]=$(this.createPop('pdiv'+this.p1.getPointNum(),this.getDistance()+'m',this.getCurX(evt),this.getCurY(evt),0,0,5));
    this.pObjs[this.pObjs.length-1].style.backgroundColor='lightyellow';
    this.pObjs[this.pObjs.length-1].style.fontSize='12px';
    this.pObjs[this.pObjs.length-1].style.padding='2px';
    this.pObjs[this.pObjs.length-1].style.whiteSpace='nowrap';
}
}
,getDistance:function()
{
if(this.p1==null||this.p1.arrX.length<2) return 0;
var dis=0;
for(var i=1;i<this.p1.arrX.length;i++)
{
    dis+=twoDistance(this.p1.arrX[i-1],this.p1.arrY[i-1],this.p1.arrX[i],this.p1.arrY[i],this.mpx,this.mpy);
}
return Math.round(dis);
function twoDistance(x1,y1,x2,y2,mpx,mpy)
{
    var x2=(x2-x1)*mpx;
    var y2=(y2-y1)*mpy;
    return Math.sqrt(x2*x2+y2*y2);
}
}
,doc_mousewheel:function(evt)
{
if(evt.wheelDelta>=120)
{
    if(!this.isZoom)
    {
        this.isZoom=true;
        this.wheelOut(true);
setTimeout(function()
{
    this.isZoom=false;
}
.bind(this),100);
}
}
else if(evt.wheelDelta<=-120)
{
if(!this.isZoom)
{
this.isZoom=true;
this.wheelOut();
setTimeout(function()
{
    this.isZoom=false;
}
.bind(this),100);
}
}
return false;
}
,wheelOut:function(flag)
{
if(!this.wheelTimer)
{
this.slowZoomBegin();
this.zz=100;
if(flag)
{
if(this.Zoom==1) return;
this.zz2=this.zz-10;
this.zz3=this.Zoom-1;
this.flag=true;
}
else
{
if(this.Zoom==4) return;
this.zz2=this.zz+10;
this.zz3=this.Zoom+1;
this.flag=false;
}
this.wheelTimer=setInterval(out.bind(this),10);
}
else if(flag)
{
if(this.zz3>1)
{
this.zz2-=10;
this.zz3--;
if(this.wheelTimeout)
{
    clearTimeout(this.wheelTimeout);
    this.wheelTimeout=null;
}
this.flag=true;
}
}
else
{
if(this.zz3<4)
{
this.zz2+=10;
this.zz3++;
if(this.wheelTimeout)
{
    clearTimeout(this.wheelTimeout);
    this.wheelTimeout=null;
}
this.flag=false;
}
}
this.setZoomBarSignPos(this.zz3);
function out()
{
    if(this.zz!=this.zz2)
    {
        if(this.flag)this.zz-=1;
        else
        {
            this.zz+=1;
        }
        var zz=Math.pow(2,(100-this.zz)/10).toFixed(3);
        this.slowZoom(zz);
    }
    else
    {
        if(!this.wheelTimeout)this.wheelTimeout=setTimeout(out2.bind(this),1000);
    }
}
function out2()
{
    clearInterval(this.wheelTimer);
    this.wheelTimer=null;
    clearTimeout(this.wheelTimeout);
    this.wheelTimeout=null;
    this.slowZoomEnd(this.zz3);
}
}
,slowZoomBegin:function()//鹰眼移动
{
    this.t1=this.mapdiv.offsetLeft;
    this.t2=this.mapdiv.offsetTop;
}
,slowZoom:function(zz)
{
    this.mapdiv.style.zoom=zz;
    this.mapdiv1.style.left=(this.t1-this.mapWidth/2)*(zz-1)/zz;
    this.mapdiv1.style.top=(this.t2-this.mapHeight/2)*(zz-1)/zz;
    this.mapdiv3.style.left=(this.t1-this.mapWidth/2)*(zz-1)/zz;
    this.mapdiv3.style.top=(this.t2-this.mapHeight/2)*(zz-1)/zz;
    this.setCopyRightZoom(1/zz);
}
,slowZoomEnd:function(z)
{
    this.zoomto(z);
    this.setZoomBarSignPos(z);
    this.mapdiv.style.zoom=1;
    this.mapdiv1.style.left=0;
    this.mapdiv1.style.top=0;
    this.mapdiv3.style.left=0;
    this.mapdiv3.style.top=0;
}
,info_onmouseover:function(evt)
{
    var src=evt.srcElement?evt.srcElement:evt.target;
    if(src._ad)
    {
        if(src.tagName=='OBJECT'||src.tagName=='IMG'||(src.tagName=='DIV'&&src.style.filter))
        {
            if(!src._w||!src._h)
            {
                src._w=src.width;
                src._h=src.height;
            }
            var w=parseInt(src._w);
            var h=parseInt(src._h);
            var zz=Math.pow(2,this.Zoom-1);
            if(w*zz>600||h*zz>600) return;
            src.style.width=w*zz;
            src.style.height=h*zz;
            src.style.position='absolute';
            src.style.left=w*(1-zz)/2;
            src.style.top=h*(1-zz)/2;
        }
    }
else
    {
    }
}
,info_onmouseout:function(evt)
{
var src=evt.srcElement?evt.srcElement:evt.target;
if(src._ad)
{
    if(src.tagName=='OBJECT'||src.tagName=='IMG'||(src.tagName=='DIV'&&src.style.filter))
    {
        src.style.width=src._w;
        src.style.height=src._h;
        src.style.left=0;
        src.style.top=0;
    }
}
else
{
}
}
,doc_keydown:function(evt)
{
    var src=evt.srcElement?evt.srcElement:evt.target;
    if(src&&(src.tagName.toLowerCase()=='input'|| src.tagName.toLowerCase() == 'textarea')) return;
    switch(evt.keyCode)
    {
        case 46:this.del();
        break;
        case 49:this.zoomto(1);
        break;
        case 50:this.zoomto(2);
        break;
        case 51:this.zoomto(3);
        break;
        case 52:this.zoomto(4);
        break;
        case 221:this.zoomax();
        break;
        case 219:this.zoomin();
        break;
        case 38:case 87:this.scrollMap(0,-10);
        break;
        case 40:case 83:this.scrollMap(0,10);
        break;
        case 37:case 65:this.scrollMap(-10,0);
        break;
        case 39:case 68:this.scrollMap(10,0);
        break;
        default:break;
    }
    if(this.mykeydown) this.mykeydown(evt);
}
,doc_keyup:function(evt)
{
    var src=evt.srcElement?evt.srcElement:evt.target;
    if(src&&(src.tagName.toLowerCase()=='input'|| src.tagName.toLowerCase() == 'textarea')) return;
    window.scroll(0,0);
    switch(evt.keyCode)
    {
        case 37:case 38:case 39:case 40:case 87:case 83:case 65:case 68:this.scrollMap();
        break;
        default:break;
    }
}
,doc_resize:function(evt)
{
    this.bodyWidth=document.body.clientWidth;
    this.bodyHeight=document.body.clientHeight;
    this.mapWidth=(this.bodyWidth>200?this.bodyWidth:200);
    this.mapHeight=(this.bodyHeight>200?this.bodyHeight:200);
    this.setComInfoPos(-150,0);
    this.adjustMiniMapPos();
    //this.zoombar.style.left=(this.mapWidth-40)+'px';
    this.mapCopyRight.style.top=(this.mapHeight-25)+'px';
    this.setMapPos();
    this.setZoomBarState();
    if(this.isInit) this.setMap();
    this.setMap();
}
,dragMap:function(evt)
{
}
,openwin:function(url,title,width,height,left,top)
{
    if(!url) return false;
    if(!title)
    {
        window.open(url);
        return false;
    }
    if(!width) width=200;
    if(!height) height=200;
    if(!left) left=0;
    if(!top) top=0;
    window.open(url,title,'menubar=no,toolbar=no,location=no,scrollbar=no,resizale=no,directories=no,width='+width+',height='+height+',top='+top+',left='+left);
}
,go2xy:function(x0,y0,onmove,onend)
{
    this.hiddenOcInfo();
    this.setMapPos(this.getXY(x0),this.getXY(y0));
    this.setMap();
}
,go2xyS:function(x0,y0,onmove,onend)
{
    this.setMapPosS(this.getXY(x0),this.getXY(y0),onmove1.bind(this),onend1.bind(this));
    function onmove1()
    {
        if(onmove) onmove();
        this.setMiniMapPos();
    }
    function onend1()
    {
        if(onend) onend();
        this.setMap();
    }
}
,getXY0:function(value)
{
    return Math.floor(Math.pow(2,this.Zoom-1)*value);
}
,getXY:function(value)
{
    return Math.floor(value/Math.pow(2,this.Zoom-1));
}
,getCurX:function(evt)
{
    var myevent=evt?evt:event;
    return this.getXY0(this.CenterX-this.mapWidth/2+myevent.clientX);
}//鼠标据原点的像素
,getCurY:function(evt)
{
    var myevent=evt?evt:event;
    return this.getXY0(this.CenterY-this.mapHeight/2+myevent.clientY);
}
,getCenterX:function()
{
return this.getXY0(this.CenterX);
}
,getCenterY:function()
{
return this.getXY0(this.CenterY);
}
,setMapTip:function(htmlStr)
{
    if(htmlStr)
    {
        this.mapTip.style.left='-20px';
        this.mapTip.style.top='-20px';
        this.mapTip.innerHTML=htmlStr;
        this.isMapTip=true;
    }
    else
    {
        this.mapTip.innerHTML='';
        this.isMapTip=false;
    }
}
,setMapCursor:function(c)
{
    if(c)document.body.style.cursor=c;
    else document.body.style.cursor='';
}
,setOption:function(option,value)
{
    if(typeof(this[option])=='undefined')
    {
        alert('Err:setValue');
        return false;
    }
    this[option]=value;
}
,setEvent:function(eventType,fun)
{
    switch(eventType)
    {
        case 'onmousedown':this.mymousedown=function(evt)
        {
            fun(evt);
        };
        break;
        case 'onmousemove':this.mymousemove=function(evt)
        {
            fun(evt);
        };
        break;
        case 'onmouseup':this.mymouseup=function(evt)
        {
            fun(evt);
        };
        break;
        case 'onAreaClick':this.myAreaClick=function(evt)
        {
            fun(evt);
        };
        break;
        case 'onUnitClick':this.myUnitClick=function(evt)
        {
            fun(evt);
        };
        break;
        case 'onkeydown':this.mykeydown=function(evt)
        {
            fun(evt);
        };
        break;
        case 'customFun':this.myCustomFun=function(evt,sign)
        {
            fun(evt,sign);
        };
        break;
        default:break;
    }
}
,selectMode:function(mode)
{
    if(brw!='ie') return;
    this.destroyAllG();
    this.mode=mode;
    if(this.mode==1)this.setMapTip('<div style="background-color:lightyellow;color:red;font-size:12px;padding:2px; ">左键划线，单击右键结束</div>');
}
,createAdPreview:function(src,w,h,x,y)
{
    this.removePop('adPreView');
    var parent=this.createPopT('adPreView','',x,y,0,0,6);
    if(!this.floatBox)
    {
        this.floatBox=new FloatBox();
        this.floatBox.setEvent('onmouseup',this.adPreview_onmouseup.bind(this));
    }
    w=Math.floor(w/Math.pow(2,this.Zoom-1));
    h=Math.floor(h/Math.pow(2,this.Zoom-1));
    this.tempData['adPreView']=
    {
        x:x,y:y
    };
    this.floatBox.createAdPreview($(parent),src,w,h);
}
,adPreview_onmouseup:function(evt)
{
    var src=evt.srcElement?evt.srcElement:evt.target;
    document.onmousemove=this.doc_mousemove.bindAsEventListener(this);
    document.onmouseup=this.doc_mouseup.bindAsEventListener(this);
    this.ptInfo=
    {
    };
    this.ptInfo.x=this.tempData['adPreView'].x+this.floatBox.getPos()['x']*Math.pow(2,this.Zoom-1);
    this.ptInfo.y=this.tempData['adPreView'].y+this.floatBox.getPos()['y']*Math.pow(2,this.Zoom-1);
    if(this.mymouseup) this.mymouseup(evt);
}
,createWelcomePop:function()
{
    var src='';
    try
    {
        src=decodeURIComponent(this.popStr);
    }
    catch(e)
    {
        src=unescape(this.popStr);
    }
    var rows=src.split(/\n/).length;
    src=src.replace(/\n/g,'<br />');
    var htmlStr='<table border="0" cellpadding="1" cellspacing="3" bgcolor="#59D2FF" style="border: 1px solid #209FE2;"> <tr> <td bgcolor="#FFFFFF"><table border="0" cellpadding="1" cellspacing="1"><tr><td style="font-size:12px;line-height:16px;" nowrap>'+src+'</td><td valign="top"><a href="javascript:mapApi.removePop(\'popWelcome\')" style="text-decoration:none"><font color="#ff6600" face="Verdana" style="cursor:pointer;font-size:9px;border: 1px solid #ff6600; padding:0px 2px;"><strong>X</strong></font></a></td></tr></table></td> </tr> </table><img src="'+this.apiPath+'/images/point.gif" width="17px" height="17px">';
    var sy=31+rows*16;
    this.createPop('popWelcome',htmlStr,this.getXY0(this.CenterX),this.getXY0(this.CenterY),0,sy,10);
}
,createPop:function(idStr,html,x0,y0,sx,sy,z)
{
    var elm=$(idStr);
    if(elm) return idStr;
    if(!x0 || !y0) return;
    if(!sx) sx=0;
    if(!sy) sy=0;
    if(!z) z=5;
    var x=this.getXY(x0);
    var y=this.getXY(y0);
    if(typeof(html)=='string')
    {
        elm=this.createDiv(idStr,x-sx,y-sy,0,0,z);
        elm.innerHTML=html;
    }
    else if(typeof(html)=='object')
    {
        elm=html;
        elm.id=idStr;
        elm.style.position='absolute';
        elm.style.left=x-sx;
        elm.style.top=y-sy;
        elm.style.zIndex=z;
    }
    elm.style.x0=x0;
    elm.style.y0=y0;
    elm.style.sx=sx;
    elm.style.sy=sy;
    this.mapdiv3.appendChild(elm);
    this.globalPop[this.globalPop.length]=idStr;
    return idStr;
}
,createPopT:function(idStr,html,x0,y0,sx,sy,z,r)
{
    var elm=$(idStr);
    if(elm) return idStr;
    if(!x0 || !y0) return;
    if(!sx) sx=0;
    if(!sy) sy=0;
    if(!z) z=1;
    var wh=256,targetZ=this.Zoom,preChar='d';
    if(r)
    {
        targetZ=r;
        wh=this.zoomvalue(this.Zoom,256,targetZ);
        preChar='r'+targetZ;
    }
    var x=this.getXY(x0);
    var y=this.getXY(y0);
    var hp1=Math.floor(x/wh);
    var vp1=Math.floor(y/wh);
    var l=x%wh-sx;
    var t=y%wh-sy;
    if(typeof(html)=='string')
    {
        elm=this.createDiv(idStr,l,t,0,0,z);
        elm.innerHTML=html;
    }
    else if(typeof(html)=='object')
    {
        elm=html;
        elm.id=idStr;
        elm.style.position='absolute';
        elm.style.left=l;
        elm.style.top=t;
        elm.style.zIndex=z;
    }
    elm._x0=x0;
    elm._y0=y0;
    var elm0=$(preChar+this.Zoom+','+hp1+','+vp1);
    if(!elm0)
    {
        elm0=this.mapdiv31.appendChild(this.createDiv(preChar+this.Zoom+','+hp1+','+vp1,hp1*wh,vp1*wh,0,0,6));
    }
    if(elm0)elm0.appendChild(elm);
    return idStr;
    }
    ,removePop:function(id)
    {
    var elm=$(id);
    if(elm)
    {
        this.svObj(elm);
        elm.parentNode.removeChild(elm);
    }
}
,removeAllPop:function()
{
    for(var i=0;i<this.globalPop.length;i++)
    {
        var elm=$(this.globalPop[i]);
        if(elm) elm.parentNode.removeChild(elm);
    }
}
//清除Ex缓存
,clrEx:function()
{
    var isDel=true;
    var elm;
    for(var i=0;i<this.oldID.length;i++)
    {
        isDel=true;
        for(var j=0;j<this.curID.length;j++)
        {
            if(this.oldID[i]==this.curID[j])
            {
                isDel=false;
                break;
            }
        }
        if(isDel)
        {
            elm=$(this.mapType+','+this.Zoom+','+this.oldID[i]);
            if(elm) elm=elm.parentNode.removeChild(elm);
            elm=$('d'+this.Zoom+','+this.oldID[i]);
            if(elm) elm=elm.parentNode.removeChild(elm);
        }
    }
    for(var i=0;i<this.curID.length;i++)
    {
        this.oldID[i]=this.curID[i];
    }
    this.oldID.length=this.curID.length;
}
,clrAll:function(z,d,arr)
{
    var elm,flag=true;
    if(!z) z=this.Zoom;
    if(!d) d=this.mapType;
    if(!arr)
    {
        arr=this.curID;
    }
    else
    {
        if(this.mapType==3&&z==this.Zoom) flag=false;
    }
    for(var i=0;i<arr.length;i++)
    {
        elm=$(d+','+z+','+arr[i]);
        if(elm)elm.parentNode.removeChild(elm);
    }
    this.isZoom=false;
}
,clrSignBox:function()
{
    this.infoState.ready('info');
    this.infoState.clear('info');
    for(var i=0;i<this.curID.length;i++)
    {
        var elm=$('d'+this.Zoom+','+this.curID[i]);
        if(elm)elm.parentNode.removeChild(elm);
    }
}
,clrHs:function()//清除hash
{
    this.hsXmlFlag=[];
    this.hsAreaFlag=[];
    this.maphs.innerHTML='';
}
,clrData:function(x,y)//清除指定缓存数据
{
    var hp1=Math.floor(x/this.zoomvalue(1,256,this.hsLoadLevel));
    var vp1=Math.floor(y/this.zoomvalue(1,256,this.hsLoadLevel));
    this.areaData[this.hsLoadLevel+','+hp1+','+vp1]=null;
    this.busStationData[this.hsLoadLevel+','+hp1+','+vp1]=null;
    this.adData[this.hsLoadLevel+','+hp1+','+vp1]=null;
    this.hsXmlFlag[this.hsLoadLevel+','+hp1+','+vp1]=false;
    this.clrHs();
}
,zoomin:function()
{
    if(this.Zoom==4) return;
    this.zoomBegin();
    this.darkMap(this.Zoom+1);
    var arr=[];
    for(var i=0;i<this.curID.length;i++)arr[i]=this.curID[i];
    this.clrMapCompleteTimer();
    this.onMapComplete=this.getFun(this.clrAll.bind(this),this.Zoom,null,arr);
    this.CenterX=Math.round(this.CenterX/2);
    this.CenterY=Math.round(this.CenterY/2);
    this.Zoom++;
    this.setGlobalPopPos();
    this.setMapPos();
    this.setMap();
    this.zoomEnd();
}
,zoomax:function()
{
    if(this.Zoom==1) return;
    this.zoomBegin();
    this.darkMap(this.Zoom-1);
    var arr=[];
    for(var i=0;i<this.curID.length;i++)arr[i]=this.curID[i];
    this.clrMapCompleteTimer();
    this.onMapComplete=this.getFun(this.clrAll.bind(this),this.Zoom,null,arr);
    this.CenterX=this.CenterX*2;
    this.CenterY=this.CenterY*2;
    this.Zoom--;
    this.setGlobalPopPos();
    this.setMapPos();
    this.setMap();
    this.zoomEnd();
}
,zoomto:function(z)
{
    if(this.Zoom==z) return;
    this.zoomBegin();
    this.darkMap(z);
    var arr=[];
    for(var i=0;i<this.curID.length;i++)arr[i]=this.curID[i];
    this.clrMapCompleteTimer();
    this.onMapComplete=this.getFun(this.clrAll.bind(this),this.Zoom,null,arr);
    this.CenterX=this.zoomvalue(z,this.CenterX);
    this.CenterY=this.zoomvalue(z,this.CenterY);
    this.Zoom=z;
    this.setGlobalPopPos();
    this.setMapPos();
    this.setMap();
    this.zoomEnd();
}
,zoomBegin:function()
{
    this.clrSignBox();
    this.infoFlag=[];
    this.mapdiv32.innerHTML='';
    this.isZoom=false;
    this.hiddenOcInfo();
}
,zoomEnd:function()
{
    this.setCopyRightZoom();
    this.lineZoom();
    if(this.type==1)this.destroyAllG();
    if(this.p1)
    {
        this.p1.setZoom(1/Math.pow(2,this.Zoom-1));
        this.p1.paint();
        this.p2.setZoom(1/Math.pow(2,this.Zoom-1));
    }
}
,darkMap:function(z)
{
    var zr,elm;
    this.mapdiv32.innerHTML='';
    if(this.Zoom-z>0)zr=Math.pow(2,this.Zoom-z);
    else zr=1/Math.pow(2,z-this.Zoom);
    for(var i=0;i<this.curID.length;i++)
    {
        elm=$(this.mapType+','+this.Zoom+','+this.curID[i]);
        if(!elm) continue;
        elm.style.left=elm.offsetLeft*zr;
        elm.style.top=elm.offsetTop*zr;
        elm.style.width=256*zr;
        elm.style.height=256*zr;
        elm.style.zIndex=-1;
    }
}
,zoomvalue:function(n,value,m)//zoomvalue(this.Zoom,256,targetZ);
{
    if(!m) m=this.Zoom;
    var a=Math.pow(2,Math.abs(m-n));
    if(m-n<0)
    {
        return Math.round(value/a);
    }
    else
    {
        return value*a;
    }
}
};
Object.extend(mapApiClass.prototype,UserPop,true);
var mapApi=new mapApiClass();
parent.o__mapStatus=true;
